I written a program with Delphi 7 which searches *.srt
files on a hard drive. This program lists the path and name of these files in a memo. Now I need convert these files from ANSI to UTF-8, but I haven't succeeded.
Please help me...
I written a program with Delphi 7 which searches *.srt
files on a hard drive. This program lists the path and name of these files in a memo. Now I need convert these files from ANSI to UTF-8, but I haven't succeeded.
Please help me...
Did you mean ASCII?
ASCII is backwards compatible with UTF-8. http://en.wikipedia.org/wiki/UTF-8
Check the code page for the source encoding. I'm not a Delphi guy but this link looks promising.
http://www.jpgriffiths.com/tutorial/api\multibytetowidechar.html
Here is some c# specific info but still helpful. http://weblogs.asp.net/ahoffman/archive/2004/01/19/60094.aspx
related info http://en.wikipedia.org/wiki/ASCII http://en.wikipedia.org/wiki/UTF-8 http://www.joelonsoftware.com/articles/Unicode.html
var
Latin1Encoding: TEncoding;
begin
Latin1Encoding := TEncoding.GetEncoding(28591);
try
MyTStringList.SaveToFile('some file.txt', Latin1Encoding);
finally
Latin1Encoding.Free;
end;
end;
The Utf8Encode function takes a WideString string as parameter and returns a Utf-8 string.
Take a look at GpTextStream which looks like it works with Delphi 7. It has the ability to read/write unicode files in older versions of Delphi (although does work with Delphi 2009) and should help with your conversion.