| Article: |
Networking in Cocoa | |
| Subject: | Problems with mot exessage handling | |
| Date: | 2003-05-29 09:06:18 | |
| From: | anonymous2 | |
|
Hi out there,
|
||
Showing messages 1 through 1 of 1.
| Article: |
Networking in Cocoa | |
| Subject: | Problems with mot exessage handling | |
| Date: | 2003-05-29 09:06:18 | |
| From: | anonymous2 | |
|
Hi out there,
|
||
Showing messages 1 through 1 of 1.
For example, if you have a string contains 1 chinese character, [message length] will return 1; but this string might be 4 bytes long.
our dataWithBytes:length method of NSData need the real length of the string in bytes. So, this results in sending the string imcompletely.
what we should do is use the strlen of C instead:
NSData *message=[[NSData dataWithBytes:[message UTF8String] length: strlen([message UTF8String])];