How do I convert many text files from <some_encoding> to utf8-no-bom?
5,064
From stackoverflow:
You can get a tool such as iconv from GnuWin32 and run a batch script to process all of your files that way. But what encoding are they now? If they're ANSI, and you're not using any bytes with values => 128, then they're already BOM-less UTF-8. Perhaps you can use that to narrow down the number of files you'd have to process - maybe enough that you only have a few files to convert (and might prefer to do it on an individual basis).
Actually, I do it with Notepad++. Before trying this, you must make a backup of your files. You need to create a macro that does this:
- Convert the currently opened file to UTF-8 w/o BOM;
- Select all the text in your file, and copy it (why this? it looks like a bug. if you won't do this, your file will be replaced with your current clipboard content...);
- Save the current file;
- Close the current file.
- Save this macro.
PHPfiles, and run it with the "Run a Macro Multiple Times..." command. If you opened 100 files, let it run for 100 times.
Related videos on Youtube
Author by
RProgram
Delphi and Python developer. Python is the main hobby now.
Updated on September 18, 2022Comments
-
RProgram over 1 year
I'm looking to convert lots of text files (40+) from ISO-Latin-1 to UTF8-no-bom. How can I accomplish this?
-
RProgram almost 11 yearsI wrote what encoding is above. ISO-Latin
-
Ramhound almost 11 yearsI could have sworn your original revision did not indicate the encoding hence the comment.
-
-
HikeMike over 10 yearsIn the future, please edit your answers to correct any mistakes instead of posting new ones.
-
pabouk - Ukraine stay strong over 10 yearsIt would be really useful to explain how to run the code.