How do I convert files between encodings where only some of them are wrong?

后端 未结 1 1159
后悔当初
后悔当初 2021-01-25 12:16

I have a large set of nested directories containing PHP, HTML, and Javascript files that should all be encoded as UTF-8. However, someone edited several of the files an

相关标签:
1条回答
  • 2021-01-25 12:57

    This would be a bit of a hack, but since it's a one-off occurrence then it might be worth it. iconv will complain about invalid encoding if it can't read the file using the encoding you give it. Therefore, you could write a wrapper script to iterate over all the files, attempting to convert them from UTF-8 to something else, and those that can't be converted have invalid UTF-8.

    0 讨论(0)
提交回复
热议问题