- Fix for formatting non-english characters, received from engine ios-revival
authorantonc27 <antonc27@mail.ru>
Sat, 24 Oct 2015 16:01:19 +0200
branchios-revival
changeset 11241 e7bae160b73b
parent 11240 57891137ffef
child 11242 1e55e4c5dda0
- Fix for formatting non-english characters, received from engine
project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m
project_files/HedgewarsMobile/Locale/English.lproj/Localizable.strings
project_files/HedgewarsMobile/Locale/ru.lproj/Localizable.strings
--- a/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m	Sat Oct 24 15:27:47 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/EngineProtocolNetwork.m	Sat Oct 24 16:01:19 2015 +0200
@@ -341,17 +341,23 @@
                 NSString *tempStr = [NSString stringWithUTF8String:&buffer[2]];
                 NSArray *info = [tempStr componentsSeparatedByString:@" "];
                 NSString *arg = [info objectAtIndex:0];
-                int index = [arg length] + 3;
+                int index = [arg lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 3;
                 switch (buffer[1]) {
                     case 'r':           // winning team
                         [statsArray insertObject:[NSString stringWithUTF8String:&buffer[2]] atIndex:1];
                         break;
                     case 'D':           // best shot
-                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"The best shot award won by %s (with %@ points)", nil), &buffer[index], arg]];
+                    {
+                        NSString *hogName = [NSString stringWithUTF8String:&buffer[index]];
+                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"The best shot award won by %@ (with %@ points)", nil), hogName, arg]];
                         break;
+                    }
                     case 'k':           // best hedgehog
-                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"The best killer is %s with %@ kill(s) in a turn", nil), &buffer[index], arg]];
+                    {
+                        NSString *hogName = [NSString stringWithUTF8String:&buffer[index]];
+                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"The best killer is %@ with %@ kill(s) in a turn", nil), hogName, arg]];
                         break;
+                    }
                     case 'K':           // number of hogs killed
                         [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%@ hedgehog(s) were killed during this round", nil), arg]];
                         break;
@@ -364,14 +370,23 @@
                         [[statsArray objectAtIndex:0] addObject:tempStr];
                         break;
                     case 's':           // self damage
-                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%s thought it's good to shoot his own hedgehogs with %@ points", nil), &buffer[index], arg]];
+                    {
+                        NSString *hogName = [NSString stringWithUTF8String:&buffer[index]];
+                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%@ thought it's good to shoot his own hedgehogs with %@ points", nil), hogName, arg]];
                         break;
+                    }
                     case 'S':           // friendly fire
-                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%s killed %@ of his own hedgehogs", nil), &buffer[index], arg]];
+                    {
+                        NSString *hogName = [NSString stringWithUTF8String:&buffer[index]];
+                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%@ killed %@ of his own hedgehogs", nil), hogName, arg]];
                         break;
+                    }
                     case 'B':           // turn skipped
-                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%s was scared and skipped turn %@ times", nil), &buffer[index], arg]];
+                    {
+                        NSString *hogName = [NSString stringWithUTF8String:&buffer[index]];
+                        [statsArray addObject:[NSString stringWithFormat:NSLocalizedString(@"%@ was scared and skipped turn %@ times", nil), hogName, arg]];
                         break;
+                    }
                     default:
                         DLog(@"Unhandled stat message, see statsPage.cpp");
                         break;
Binary file project_files/HedgewarsMobile/Locale/English.lproj/Localizable.strings has changed
Binary file project_files/HedgewarsMobile/Locale/ru.lproj/Localizable.strings has changed