开发者

Any tool to convert bulk php files to UTF-8 without BOM? [closed]

开发者 https://www.devze.com 2022-12-24 02:49 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 5 years ago.

开发者_运维知识库 Improve this question

I have a very large script which contains a lot of php files, so I need some Windows tool to convert all those files into UTF-8 without BOM. (I know this can be done with Notepad++ but would require doing each file separately.)


I have used with success UTFCast on Windows.

It has a GUI, and is very easy to use, so you don't have to fiddle with command line scripts.

There's an "Express" free version that can do what you want, and a Pro version with more options (has a 14 day trial).

You can see here a comparison chart of both versions, to see if it suits your needs.

Express detects less codepages, but for me its worst defect is that has no filter, for only process PHP files and not JS for example.

Any tool to convert bulk php files to UTF-8 without BOM? [closed]

The Pro version beyond the 14 days can be used to browse folders and detect encoding of files, but not to convert.

Any tool to convert bulk php files to UTF-8 without BOM? [closed]


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:

  1. Convert the currently opened file to UTF-8 w/o BOM;
  2. 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...);
  3. Save the current file;
  4. Close the current file.

Save this macro.

Now, open your PHP files, and run it with the "Run a Macro Multiple Times..." command. If you opened 100 files, let it run for 100 times.


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).


At the bottom of this page you’ll find a VBscript which converts any number of files per drag and drop.

0

精彩评论

暂无评论...
验证码 换一张
取 消