1

Possible Duplicates:
Batch-convert files for encoding or line ending under Windows
App to convert from ANSI to UTF8 on windows

Hi,

currently i'm in need of a way to convert loads of .txt files in ANSI to UTF8, since i just found out that a app i'm making doesnt recognize accents when they are in ANSI.

I've tried cp converter, but it doesnt work... not only the files after converting still appear as ANSI, but it also doesnt recognize the accents, replacing them with a ?, which is basically the problem i have in my app.

2

1 Answer 1

4

with powershell you can do something like this:

%  get-content IN.txt | out-file -encoding ENC -filepath OUT.txt

while ENC is something like unicode, ascii, utf8, utf32. checkout 'help out-file'.

to convert all the *.txt files in a directory to utf8 do something like this:

% foreach($i in ls -name DIR/*.txt) { get-content DIR/$i | out-file -encoding utf8 -filepath DIR2/$i }

which creates a converted version of each .txt file in DIR2.

2
  • this is a good answer (afaik, i'm not a powershell user) and i don't think it's been posted on any of the related/similar questions. if you would, please post it as an answer to the master question: superuser.com/questions/27060 ... thanks! Feb 25, 2010 at 19:18
  • consider it done :)
    – akira
    Feb 26, 2010 at 6:32