- Fix for sending to engine non-english characters ios-revival
authorantonc27 <antonc27@mail.ru>
Sat, 24 Oct 2015 15:27:47 +0200
branchios-revival
changeset 11244 57891137ffef
parent 11243 a954853e9c00
child 11245 e7bae160b73b
- Fix for sending to engine non-english characters Note: Actually fixes problem with cyrillic team and hogs names
project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m
project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m
project_files/HedgewarsMobile/Classes/ServerProtocolNetwork.m
--- a/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m	Sat Oct 24 03:56:02 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m	Sat Oct 24 15:27:47 2015 +0200
@@ -197,7 +197,7 @@
 
 // wrapper that computes the length of the message and then sends the command string, saving the command on a file
 -(int) sendToEngine:(NSString *)string {
-    uint8_t length = [string length];
+    uint8_t length = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
 
     [self dumpRawData:[string UTF8String] ofSize:length];
     SDLNet_TCP_Send(csd, &length, 1);
@@ -206,7 +206,7 @@
 
 // wrapper that computes the length of the message and then sends the command string, skipping file writing
 -(int) sendToEngineNoSave:(NSString *)string {
-    uint8_t length = [string length];
+    uint8_t length = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
 
     SDLNet_TCP_Send(csd, &length, 1);
     return SDLNet_TCP_Send(csd, [string UTF8String], length);
--- a/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m	Sat Oct 24 03:56:02 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/MapPreviewButtonView.m	Sat Oct 24 15:27:47 2015 +0200
@@ -58,7 +58,7 @@
 #pragma mark -
 #pragma mark preview
 -(int) sendToEngine:(NSString *)string {
-    unsigned char length = [string length];
+    unsigned char length = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
 
     SDLNet_TCP_Send(csd, &length, 1);
     return SDLNet_TCP_Send(csd, [string UTF8String], length);
--- a/project_files/HedgewarsMobile/Classes/ServerProtocolNetwork.m	Sat Oct 24 03:56:02 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/ServerProtocolNetwork.m	Sat Oct 24 15:27:47 2015 +0200
@@ -69,14 +69,14 @@
 #pragma mark Communication layer
 -(int) sendToServer:(NSString *)command {
     NSString *message = [[NSString alloc] initWithFormat:@"%@\n\n",command];
-    int result = SDLNet_TCP_Send(self.ssd, [message UTF8String], [message length]);
+    int result = SDLNet_TCP_Send(self.ssd, [message UTF8String], [message lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
     [message release];
     return result;
 }
 
 -(int) sendToServer:(NSString *)command withArgument:(NSString *)argument {
     NSString *message = [[NSString alloc] initWithFormat:@"%@\n%@\n\n",command,argument];
-    int result = SDLNet_TCP_Send(self.ssd, [message UTF8String], [message length]);
+    int result = SDLNet_TCP_Send(self.ssd, [message UTF8String], [message lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
     [message release];
     return result;
 }