Search code examples
xmlbatch-filevbscriptspecial-characters

How do I use echo command with special characters


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?


Solution

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