Lazarus
Programming => Operating Systems => iPhone/iPad => Topic started by: CCRDude on November 25, 2014, 09:54:54 am
-
I recently implemented my first iOS app using FreePascal and based it upon simonsayz' great demos. His iOS_Controls unit makes things really easy.
While working with that, I came across a bug - while FPC Unicode support (http://"http://wiki.freepascal.org/FPC_Unicode_support") refers to UTF-8 as the code charset, his units ignore the charset by using NSStr() from unit CoreFoundation.pas.
His iOS_Controls folder already contains unit NSHelpers.pas, which offers a better procedure (StrToNSStr). If we wrap this procedure into a function, NSStrUTF8 in the example, we can use hard-coded UTF-8 strings with only minor changes to his code.
function NSStrUTF8(AText: String): NSString;
begin
StrToNSStr(AText, Result, kCFStringEncodingUTF8);
end;
Procedure TiOSTextView.Lines_Append( Str : String );
begin
FControl.setText( FControl.Text.stringByAppendingString
// ( NSStr(PChar(Str))) );
( NSStrUTF8(Str)) );
end;
Procedure TiOSTextView.Lines_Add ( Str : String );
begin
FControl.setText( FControl.Text.stringByAppendingString
// ( NSStr(PChar(Char(13)+Str)) ) );
( NSStrUTF8(Char(13)+Str) ) );
end;
I did the same changes in a few other places with success (SetTabBar, various Captions and Prompts).
Haven't found a better place to report the bug yet, will email him as well, but in case anyone else is stumbling across this issue, here's the solution.
-
:)
Thanks a lot.
I will fix the code as you point.
Best Regards
Simon,Choi