cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How do you batch convert UTF-16 to UTF-8?

Level 4

How do you batch convert UTF-16 to UTF-8?

Hi, I have a lot of files that I have exported from the AAD CSDB and I want to convert them in bulk from UTF-16 to UTF-8. I am familiar with the following ACL:

save_as -encoding utf-8 myfilename.xml

This works but is too laborious to repeat for every file. So, I have attempted to create a Windows Command Line batch file to open Arbortext Editor and execute the command on the files in a local directory using the -c switch. At the moment I get nothing out of it. The script does not open a dialog and ask to save the file. I would prefer to merely replace the current file. Does anyone have a suggestion as to how the script might be improved in order to process multiple files?

:REM convert all files in directory from UTF-16 to UTF-8

ECHO *********************

ECHO CONVERT UTF16 TO UTF8

ECHO *********************

for %%f in (*.xml) do ( "C:\Program Files (x86)\PTC\Arbortext Editor\bin\x86\editor.exe" -c "save_as -encoding utf-8" %%f )

ECHO *********************

ECHO D O N E

ECHO *********************

2 REPLIES

Re: How do you batch convert UTF-16 to UTF-8?

Start with a simpler batch file that just prints out the XML names on screen then build it up from there. Your syntax looks pretty close to correct so there is probably not much wrong. One thing I would do is double-quote the final %%f variable as Windows command line won't process files containing spaces otherwise.

Re: How do you batch convert UTF-16 to UTF-8?

Thank you for taking the time to reply. I'll rewrite this. By  the way Adobe CS4 Dreamweaver will also save files to UTF-8.

Open the file with Dreamweaver, from the menu select: Modify/Page Properties, from the dialog box select Document Encoding: using the drop down menu choose Unicode (UTF-8),

Click OK

From the menu choose File/Save.

Close the file.

 

UTF-8 usually cuts the file size in half, approximately.I have no idea how reliable this is.