Sunday, December 1, 2013

NSUTF8StringEncoding transcoding sometimes succeed, sometimes fail

char * deal;
deal = (char *) malloc (5);
memset (deal, 0, 5);
memcpy (deal, data.bytes +52,4);
memcpy (deal +4, "\ 0", 1);
NSString * dealresult = [NSString stringWithCString: deal encoding: NSUTF8StringEncoding];
For the receiver over the same data, dealresult sometimes values ​​transcoding, sometimes nil, do not know where is the problem?
Reply:
The same data it?
When the data to be converted should be wrong
Reply:
cited a floor reply: The same data
it?
When the data to be converted should be wrong

Yes, the same instruction is sent to the server, and then pass back data parsing after nsutf8stringencoding transcoding, I doubt not as likely to be parsed data back from time to time, but I see looks like claw package is the same, the interception data.bytes +52 in front of the data has not changed, converting normal, sometimes the problem is back, as well as other conditions can cause this problem?
Reply:
cited a floor reply: The same data
it?
When the data to be converted should be wrong

[Img =] [/ img] [img =] [/ img]

The first and second param param is the same data, but a content summary first, the second was empty
Reply:
cited a floor reply: The same data
it?
When the data to be converted should be wrong


[Img = http://my.csdn.net/my/album/detail/1215762] [/ img]
Reply:
Look at the data inside is not 0, so turn on the end of a string
Reply:
How to convert the same data to be wrong then, a few lines of code inside and no random function. The data is not being installed for utf8 encoding, conversion result is nil
Reply:
references, 5th Floor reply:
look at the data there is not a 0, so turn on the end of a string
< br />
This is a comparison of successful and unsuccessful in two param value, is the same way, did not get to know how it is, actually sometimes to nil after
Reply:
references 6th Floor reply:
same data conversion how it will go wrong, which is a few lines of code inside and no random function. The data is not being installed for utf8 encoding, conversion result is nil

Should all utf8

No comments:

Post a Comment