Implementation of content Unicode encoding when IOS simulates SOAP request WebService using HTTP

Source: Internet
Author: User
Tags http post soap

iOS to request WebService, for convenience, directly with the HTTP POST request. Through the Java version of the capture discovery, the request in the Chinese characters, are converted to Unicode encoding.

Such as: A is changed to & #97;

"Actually very simple, get the corresponding number of each character, such as 999,unicode encoding is:& #999; 】

In order to implement the relevant functions, the string is manually spliced, the code is as follows:

-(NSString *) Convert2unicode: (NSString *) str{nsmutablestring*resultstring =[[Nsmutablestring alloc]init]; Nsinteger length=[str length];  for(intI=0; i<length; i++) {       //NSLog (@ "convertstring2unicode ****** charatindex%d is%c code:&#%d;", I,[str characteratindex:i],[str CHARACTERATINDEX:I]);[Resultstring appendstring:[nsstring stringWithFormat:@"&#%d;", [str characteratindex:i]]; }    returnresultstring;}

I did not test the effect of the direct string, welcome to the guidance.

Implementation of content Unicode encoding when IOS simulates SOAP request WebService using HTTP

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.