views:

12

answers:

1

I am writing a batch script to go through some directories doing an specific task, something like the following:

set DBCreationScript=//Here I set the full path for the script
echo %DBCreationScript%

Problem is the path has got some latin characters (ç, ã, á) and when I run the script, the output shows strange characters, not the ones I typed in. The batch script is in ANSI encoding.

I already tried to set the script encoding to UTF-8, but apparently the batch interpreter can't handle the control characters that appear on the beggining of the file.

Any thoughts?

+1  A: 

Save the batch file in OEM encoding (a decent editor should allow this) or change the code page prior to running it with

chcp 1252

You can also save it as UTF-8 without signature (BOM) and use

chcp 65001

but down that path lies peril and dragons await to eat you (in short: It's usually painful and has a few weird side-effects).

Joey
As a side note: OEM couldn't handle 'ã', only the other two chars (at least on my editor, notepad++). Anyway, chcp did the trick.
Rodrigo Gama
Well, that depends on which OEM codepage you're using. 850 (which is the default on my machine) supports it. But yes, that's the usual problem with non-Unicode encodings and a major reason why they should die already.
Joey