Forum > General
Charset conversions
(1/1)
Rodrigo Robles:
Hi friends,
I'm loading an ANSI TXT file into a TStringList and want to show some data in a TEdit. I have some extended ASCII chars into the file, but TEdit doesn't show these chars, even if I try converting it using AnsiToUtf8.
I wrote this short code to show what happens:
SetLength(Str,50);
AssignFile(FileVar,'teste2.txt');
Reset(FileVar,47);
Seek(FileVar,2);
BlockRead(FileVar,Buf,1);
for c := 1 to 47 do
Str[c] := Chr(Buf[c]);
Label1.Caption := AnsiToUTF8(Str);
CloseFile(FileVar);
The character 'ã' are shown as '?'. If I don't use AnsiToUTF8, just shows a crossed block.
What should be the right way to do it?
The file 'teste2.txt' follows attached.
User137:
Have you tried SysToUTF8 or even other way around (for some reason) UTF8ToSys?
Arbee:
On Windows it works fine. Are you on Linux or Mac?
You might consider converting your file to UTF8 already.
On *NIX machines (Unix, Linux, Mac) that is done on the command line with the "iconv" tool.
Navigation
[0] Message Index