Find Out a File’s Encoding On Windows
Recently, I needed to know whether a file was encoded in UTF-8 or not. Since everything is international nowadays (especially websites), you might as well encode everything in UTF-8 so no funky characters appear. Although there are many encoding schemes, Notepad was pretty easy to use to see whether a text file was encoded in UTF-8 or not. Here’s what I did:
- Open a text file (e.g. index.php),
- Click File -> Save As
- Look as what is selected in the Encoding field. If it’s not UTF-8, then it’s not UTF-8, and you can select UTF-8 and save it as UTF-8.
If anyone finds a simple way to automate this in a loop to convert a batch of files, let me know in the comments. I read many posts on automating this in PHP.net comments but they didn’t seem reliable.
Actually, I just found out you can use the free Notepad ++
to convert from ANSI to UTF-8 and to other character encodings.