views:

3202

answers:

5

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...

A: 

Did you mean ASCII?

ASCII is backwards compatible with UTF-8. http://en.wikipedia.org/wiki/UTF-8

jms
No, I mean ANSI. Open a txt file.(notepad) File----> save as -------> encoding ------> ANSI or UTF-8 or... ----> SAVE I hope, this helps to see my aim...
A: 

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

jms
A: 
var
  Latin1Encoding: TEncoding;
begin
  Latin1Encoding := TEncoding.GetEncoding(28591);
  try
       MyTStringList.SaveToFile('some file.txt', Latin1Encoding);
  finally
      Latin1Encoding.Free;
  end;
end;
pho3nix
This is Delphi 2009.
Ralph Rickenbach
+1  A: 

The Utf8Encode function takes a WideString string as parameter and returns a Utf-8 string.

mjustin
A: 

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.

skamradt