Pergunta

I have a XML file with some information, I've made a vbscript to replace informations on this XML file. It works fine, my problem is the special characters, example:

<string name="information_1">ÁÉÍÓÚ</string>

My vbscript read it, and my script try to place the content of <string> tag to a textFile:

@echo off
for /f "tokens=*" %%a in ('cscript //nologo readXML.vbs') do (echo/%%a>>textFile.txt)

The content of textFile is now: µÖàé

Is there a way to use echo to place ÁÉÍÓÚ to a text file?

Foi útil?

Solução

A file does not contain 'characters' (letters/symbols/glyphs/images that look like A or Z) but numbers. The (person configuring the) agent that displays those numbers decides the encoding (mapping of numbers to letters/symbols/glyphs/images).

See:

chcp
Active code page: 850

echo ÁÉÍÓÚ >0.txt

debug 0.txt
-d 100
0BFA:0100  B5 90 D6 E0 E9 20 0D 0A-E4 75 21 8A F0 2E A1 58 <-- these numbers never change

type 0.txt
ÁÉÍÓÚ <-- 850 glyphs for those numbers

chcp 1256
Active code page: 1256

type 0.txt
µگضàé  <-- 1256 glyphs for those numbers

So decide which encoding scheme you want to/must use and then configure your display tools (console, editor, browser, ...) properly.

Outras dicas

Try this:

Make a text file called Char.txt and put ÁÉÍÓÚ in the text file. Make sure the text file is in the same folder as the batch file.

@echo off
SetLocal EnableDelayedExpansion
for /f "delims=" %%x in ('type Char.txt) do ( 
    set "Var=%%x"
    ECHO !Var!>>textFile.txt
)
echo Done
pause

This will read Char.txt and echo it to textFile.txt. I dont think there is any other way because CMD spites thinks it doesn't know.

I suspect you need to launch your CMD.EXE in a Unicode-friendly way (CMD.EXE /U /C <script>)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top