MegaBits / SIOSocket

Realtime iOS application framework (client) http://socket.io
MIT License
494 stars 80 forks source link

UTF8 problem #49

Closed andrew-frank closed 9 years ago

andrew-frank commented 9 years ago

I have the latest version from cocoapods (with socket.io-1.2.1.js) and there are no special characters accepted in UTF-8 (e.g. Ł changes to A, emoticons to random numbers etc.).

I did test the socket using web client, it's just doesn't work on my mobile.

I discovered it actually happened when I migrated from version 0.0.3 to 0.1 - when I use 0.1 and above the encoding is bad.

In 0.0.3 UTF-8 works but I would prefer to use newest one, because there was one pull that allows specifying transportation (helped me to make it work on Heroku with multiple dynos). Btw it would be nice to merge it.

P.S. This is the way I do it in version 0.0.3 which accepts NSString only and I need to send a dictionary:

{
        ....
        NSDictionary *message = @{@"body": text, @"room": self.chatRoomModel.ID};
        NSError *error;
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:message options:0 error:&error];

        if (jsonData) {
            NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
            [self.socket emit:@"msg", jsonString, nil];
        }
}
andrew-frank commented 9 years ago

Ok update on the serverside did the job. But still please merge the pull https://github.com/MegaBits/SIOSocket/pull/38 really helpful