up vote 0 down vote favorite
share [g+] share [fb]

Possible Duplicate:
Batch-convert files for encoding or line ending under Windows

I need a tool like this
http://www.rotatingscrew.com/utfcast.aspx

But the tool should do the opposite, convert multiple files from utf-8 to iso-8859-1

Is there any tool (php script, batch file, etc.) for Windows that can do this? Thanks

link|improve this question
most of those questions are about converting TO utf-8, but any of those batch tools should be able to convert in either direction. – quack quixote Nov 11 '09 at 17:14
feedback

closed as exact duplicate by quack quixote, Diago Feb 25 '10 at 18:33

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ.

3 Answers

up vote 3 down vote accepted

You can use iconv from GNUWin32, it works the same as the GNU/Linux counterpart:

iconv -f UTF-8 -t ISO-8859-1 filename.txt

you can then use it with batch, provided you've added it to your %PATH%:

for /f %x in ('dir /b *.txt') do iconv -f UTF-8 -t ISO-8859-1 %x
link|improve this answer
Iff the Windows port is at least half-way sane (I know, many of them aren't and GNUWin32 was a long-time offender in that area) you could simply pass *.txt to iconv. I never really expect it from ported applications but sometimes there are people with an eye for details working on them and then such things are fixed and globbing is done within the application. Might be the case here. – Joey Nov 12 '09 at 7:50
Great! worked great!! – Enrique Nov 13 '09 at 16:53
feedback

I wrote a DOS/Windows shell utility to do this. The source code is open source C++, so it can be ported to other systems.

Look for crlf.cppat david.tribble.com/src/src.html
The executable is at david.tribble.com/programs.html

link|improve this answer
Great! I'll try it. I wish I could select multiple answers. Thanks!! – Enrique Nov 13 '09 at 16:39
Well, you can upvote as many good answers as you want. – Loadmaster Nov 13 '09 at 22:23
feedback

ConvertEncoding is simple command line utility for file encoding conversion

Requirements: Java Virtual Machine, JRE 1.4+

Convert multiple files from one encoding into another

Usage: java -jar Util.jar convertfiles [-fenc <from_encoding>] [-tenc <to_encoding>] -tdir <to_directory> files..

Reads the specified files using the encoding from_encoding (or if not specified using the default encoding). Writes copies of these files into the directory to_directory using the encoding to_encoding (or if not specified using the default encoding).

Example:
[localhost:~/]$ java -jar Util.jar convertfiles -fenc UTF-8 -tenc ISO-8859-1 -tdir outdir *.html
[INFO] Converting index.html.
[INFO] Converting navigation.html.
[INFO] Converting download.html.
[INFO] Converting readme.html.
Finished.
link|improve this answer
Great! I'll try it. I wish I could select multiple answers. Thanks!! – Enrique Nov 13 '09 at 16:57
You're welcome! – Sathya Nov 13 '09 at 17:14
The link to ConvertEncoding is dead. – Stephan Nov 10 '11 at 11:29
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.