title: Text encoding on WScript arguments
body: <p>I'm trying to generate mail configurations and personalized signatures through a batch file that reads a list of users, a template, and creates a personalized output. That's done and works:</p>
  
  <pre><code>@ECHO OFF
  SETLOCAL ENABLEEXTENSIONS
  GOTO begin
  :writesignature
  cscript //NoLogo replacetext.vbs "[NAME]" %1 signature.html stdout | cscript //NoLogo  replacetext.vbs "[JOB]" %3 stdin stdout | cscript //NoLogo replacetext.vbs "[EMAIL]" %2 stdin signature-%4.html
  GOTO :end
  :begin
  FOR /F "tokens=1,2,3,4 delims=;" %%A IN ('TYPE people.lst') DO CALL :writesignature "%%A" "%%B" "%%C" %%D
  :end
  </code></pre>
  
  <p>To do the text replacing, I created replacetext.vbs, that allows me to replace a string for oter, and can be piped if stdin and stdout are indicated as the source and target files:</p>
  
  <pre><code>CONST ForReading = 1
  CONST ForWritting = 2
  CONST ForAppending = 8
  CONST OpenAsASCII   = false  
  CONST OpenAsUnicode = true
  CONST OpenAsDefault = -2
  Const OverwriteIfExist = true
  Const FailIfExist      = false
  Const CreateIfNotExist = true
  Const FailIfNotExist   = false
  SET objFSO = CreateObject("Scripting.FileSystemObject")
  SET objFILEINPUT = Wscript.StdIn
  SET objFILEOUTPUT = Wscript.StdOut
  IF (Wscript.Arguments.Count &lt; 2) OR (Wscript.Arguments.Count &gt; 4) THEN
  Wscript.Echo "Not enought arguments"
  Wscript.Echo "replacetext ""&lt;original&gt;"" ""&lt;replacement&gt;"" "
  Wscript.Quit(1 MOD 255)
  END IF
  IF Wscript.Arguments.Count &gt; 2 THEN
      IF Wscript.Arguments(2) = "stdin" THEN
  '       Wscript.Echo "Input: StdIn"
      ELSE
  '       Wscript.Echo "Input: " + Wscript.Arguments(2)
          SET objFILEINPUT = objFSO.OpenTextFile(Wscript.Arguments(2), ForReading, OpenAsASCII)
      END IF
      IF Wscript.Arguments.Count = 4 THEN
          IF Wscript.Arguments(3) = "stdout" THEN
  '           Wscript.Echo "Output: StdOut"
          ELSE
  '           Wscript.Echo "Output: " + Wscript.Arguments(3)
              IF objFSO.FileExists(Wscript.Arguments(3)) THEN
                  SET objFILEOUTPUT = objFSO.OpenTextFile(Wscript.Arguments(3), ForWritting, CreateIfNotExist, OpenAsASCII)
              ELSE
                  SET objFILEOUTPUT = objFSO.CreateTextFile(Wscript.Arguments(3), OverwriteIfExist, OpenAsASCII)
              END IF
          END IF
      END IF
  END IF
  strText = objFILEINPUT.ReadAll()
  strNewText = Replace(strText, Wscript.Arguments(0), Wscript.Arguments(1))
  objFILEOUTPUT.Write(strNewText)
  objFILEOUTPUT.Close
  objFILEINPUT.Close
  Wscript.Quit(0 MOD 255)
  </code></pre>
  
  <p>The problem is that when I put non-ASCII characters in ANSI/Windows-1250 in the people.lst (<code>Comunicación</code>), while it works and reads them in console, showing them (not converting them) as OEM characters (<code>Comunicaci¾n</code>) when I write the output files, somehow it does convert them transparently, so the output file in Windows shows <code>Comunicaci¾n</code> instead of <code>Comunicación</code>.</p>
  
  <p>After much debugging, I've localized the problem in ONLY the arguments (no automatic conversion on the template file).</p>
  
  <p>How can I disable said transparent conversion, or convert back the input from ANSI to OEM so the conversion works as intended?</p>