Computer Hope

Microsoft => Microsoft DOS => Topic started by: 99miles on May 24, 2006, 10:23:01 AM

Title: Writing ANSI txt files instead of Unicode???
Post by: 99miles on May 24, 2006, 10:23:01 AM
I have a batch file that exports some registry keys and values to a text file. Then I need to read the text file in via PHP, but the batch file writes the text file in Unicode, and PHP 5 doesn't support Unicode (I can't switch to PHP6).

Is there a way to get the batch file to write in ANSI, or... any other ideas? THanks!
Title: Re: Writing ANSI txt files instead of Unicode???
Post by: ghostdog74 on May 24, 2006, 10:50:40 AM
what commands did you use to export the registry?
Title: Re: Writing ANSI txt files instead of Unicode???
Post by: 99miles on May 24, 2006, 11:00:47 AM
I'm just using:

@REG EXPORT %RegKeyLocation% textfile.txt

thanks
Title: Re: Writing ANSI txt files instead of Unicode???
Post by: Sidewinder on May 24, 2006, 03:12:22 PM
If you have WinXP or 2000,  just run the file thru the type command:

type Unicode.txt > ASCII.txt

Also check to see if your version of the copy command supports the /a switch. You may be able to use that on the output side of the command.

 8-)

Title: Re: Writing ANSI txt files instead of Unicode???
Post by: DosItHelp on May 24, 2006, 09:24:51 PM
99miles,

The TYPE example provided by Sidewinder works correctly when CMD.EXE runs in ANSI mode.  To make sure it does run a new instance with the /A switch like this:

cmd [highlight]/A[/highlight] /c type textfile.txt>ansifile.txt[/b]

Similary you can convert an ANSI file to UNICODE:

cmd [highlight]/U[/highlight] /c type textfile.txt>unicodefile.txt[/b]

Ref:http://dostips.cmdtips.com/DosCommandRef.htm#cmd

Hope this information is useful. ;)