Monday, December 16, 2013

iphone communications ascii turn utf8string Chinese output.

I use CFSocket communication server is ascii Mary, I now accept, all the way inside with NSString method did not convert into Chinese, I am attaching a picture, I have the card for a week, please help help me.

Reply:
The reply was deleted at the moderator 2011-05-06 08:42:38

Reply:
[NSString stringWithCString: string encoding: NSASCIIStringEncoding];
Do not jump to conclusions

Reply:
+ (Id) stringWithCString: (const char *) cString encoding: (NSStringEncoding) enc;

Also, there is a static method, it is best not to have been alloc
Reply:
My TCHAR is char. NSString playing out now with all garbled. Is not the first turn into unichar, then turn into UTF8char? Or something, I used the method you said, or garbled.
Reply:
iphone certainly support the Chinese, but not defined in this NSString enumeration values, we can get this through two methods of enumeration values ​​
The first method is by CFStringConvertEncodingToNSStringEncoding
For example: NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding (kCFStringEncodingGB_18030_2000);
NSString * str2 = [NSString stringWithCString: str1 encoding: enc];
All of kCFStringEncoding defined reference CFStringEncodingExt.h
Also useful are CFStringConvertIANACharSetNameToEncoding
Reply:
The reply was deleted at the moderator 2011-05-16 08:53:15

Reply:
Class website design and production thesis
Such masters thesis how to write about my mailbox wwwyecao@163.com
Reply:
Class website design and production thesis

Reply:
UTF-8 is sometimes difficult ah
Reply:
The reply was deleted at the moderator 2011-05-16 08:55:06

Reply:
The reply was deleted on 2011-05-16 08:56:27 moderator

Reply:
The reply was deleted at the moderator 2011-05-16 08:59:21

Reply:
Concerned about the topics discussed
Reply:
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
Reply:
The reply was deleted at the moderator 2011-05-16 09:01:18

Reply:
The reply was deleted on 2011-05-16 09:02:47 moderator

Reply:
The reply was deleted at the moderator 2011-05-16 10:16:21

Reply:
The reply was deleted on 2011-05-16 10:16:56 moderator

Reply:
Concerned about the topics discussed
Reply:
Blackberry is not fun.
Reply:
The reply was deleted at the moderator 2011-05-17 08:53:46

Reply:
trety
Reply:
Niu ah good
Reply:
The reply was deleted at the moderator 2011-05-17 08:24:25

Reply:
The reply was deleted at the moderator 2011-05-17 09:09:52

Reply:
NSString stringWithCString: string encoding: NSASCIIStringEncoding];

Reply:
NSURL * url = [NSURL URLWithString: urlStr];
NSData * data = [NSData dataWithContentsOfURL: url];
NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding (kCFStringEncodingGB_18030_2000);
NSString * retStr = [[NSString alloc] initWithData: data encoding: enc];

Baidu, the landlord try

Reply:
The reply was deleted at 2011-05-18 08:43:23 moderator

Reply:
Too complicated! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! Learn again
Reply:
The reply was deleted at 2011-05-18 08:43:49 moderator

Reply:
The reply was deleted at 2011-05-18 09:28:36 moderator

Reply:
Learning, new arrival, waiting for experts to solve
Reply:
Yes, high
Reply:
Yes, high
Reply:
Hahaha reports
Reply:
NSString stringWithCString: string encoding: NSASCIIStringEncoding];
/ * Char or NSString change * /

char a [] = [NSString UTF8String];
NSString = [[NSString alloc] initWithUTF8String: a]

/ * Gb2312 or utf8 chare * /
Reply:
IOS developers recommend a good text http://blog.csdn.net/iukey/article/details/7083165
Reply:
http://blog.csdn.net/iukey/article/details/7083165

No comments:

Post a Comment