PDA

View Full Version : Utf8



wagenheimer
20-12-2011, 01:39 PM
Hi Guys!

I'm having some strange problems loading a Text File with Japanese Characters saved like UTF8.

I need to load it to a stringlist and proccess it line by line.

I have this simple code:



AStringList.LoadFromFile(AFileName);
for AIndex := 0 to AStringList.Count - 1 do
begin
ALine := AStringList[AIndex];
Proccess(ALine);
end;


This code works on Windows/Mac but does not works on iOS.

What do you suggest? Do I realy have to save the txt file like UTF8 or do I need to use something else?

Stoney
20-12-2011, 03:44 PM
You may want to take a look at FreePascal's UTF8 functions, maybe some of those could help you: http://wiki.freepascal.org/LCL_Unicode_Support
Or this won't help you may need to use some Objective-Pascal or Objective-C classes specifically NSString, you could use [NSString stringFromUTF8String], but then you would need to use NSStrings or convert them back.
May I ask why aren't using the usual string localization method (a *.strings file with localizable string in the form of "MyString" = "Something"; ) provided by Xcode? (Sure, you would need to use some Objective-Pascal or Objective-C for that as well)

wagenheimer
21-12-2011, 01:54 PM
Thanks for the help!

Well... the problem really was not with my Strings, and it was something wrong with my Font Class. I don't know what was wrong and why it works on Windows/Mac and does not works on iOS, but it were not very optimized anyway and so I decided to abandon it!

I changed it to ZenGL native font and now it works like a charm! =)

Now I just saves the text file like UTF8 and I don't need to use nothing different when loading it.