Women in Technology

Hear us Roar



Article:
  Networking in Cocoa
Subject:   Problems with mot exessage handling
Date:   2003-05-29 09:06:18
From:   anonymous2
Hi out there,


I found two small things that seems to need some improvement:
1) If the message to be sent contains a ":" the message is not handled correctly by the receiver. It is just skipped as it does not have 3 but 4 ":"
2) If the "login name" contains a non ascii character, for example a , the message is not transmitted correctly. The last character is missing.


Greetings
Peter

Full Threads Newest First

Showing messages 1 through 1 of 1.

  • Problems with mot exessage handling
    2003-05-30 00:14:50  anonymous2 [View]

    the second problem is caused by the [message length] statement in sendMessage method is return the character's number by Unicode encoding.

    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])];