Hello everyone,
I'm having a problem with Lazarus on MacOS X for PowerPC. I'm using MacOS X 10.5.
I have written a program that connects to a MySQL Database in Windows on Lazarus 0.9.30.4 (under .2 I'm having the same problem). Now when I access the database and retrieve data I am converting it to an Ansi-String with Utf8-Decode and then use it in my program (for demonstration I just make a ShowMessage). Under Windows that works perfectly fine.
Now when I am doing the same thing on MacOS X all the Umlauts are displayed as "?". First I thought the error probably lies in the TMySQLConnection, so I tried the same thing with Zeos. But the result is the same.
Then instead of displaying the string to the screen I stored the information to a StringList and dumped it into a file, also with the same result. However if I don't use the DecodeUTF8-function but instead write the raw-information into a stringlist, dump it into a file and then reimport it into a stringlist under Windows and then use DecodeUTF8 from within the windows-program I get the result that I am expecting. If I interpret that correctly it is looking to me like if the access to the database works fine but DecodeUTF8 doesn't work correctly under MacOSX, is that right?
Can anybody explain that effect to me or does anyone have a workaround?
Thanks folks
Here's some sourcecode
var
sl : TStringList;
save : TSaveDialog;
u : UTF8String;
s : AnsiString;
begin
if NOT DBConnection.Connected then
exit;
save := TSaveDialog.Create(self);
//if not save.Execute then exit;
//if save=NIL then exit;
LB.Clear;
sl := TStringList.Create;
Query.Close;
Query.Open;
while NOT Query.EOF do
begin
sl.Add( Utf8ToSys(Query.FieldByName('NAME').AsString));
s:= (Utf8Toansi(Utf8ToSys( Query.FieldByName('Name').AsString)));
//s := 'tätätü';
ShowMessage (s);
//ShowMessage(Query.FieldByName('Name').AsString);
//LB.Items.Add( ConvertEncoding(Query.FieldByName('NAME').AsString,GuessEncoding(Query.FieldByName('NAME').AsString),EncodingUTF8BOM));
//ShowMessage ( UTF8Decode( Query.FieldByName('NAME').AsString) );
Query.Next;
end;
// sl.SaveToFile(save.FileName);