title: Why WScript.StdOut.Write method behaves differently in VBS vs. JScript?
body: <p>I have two small programs in VBS and JScript:</p>
  
  <p><strong>VBScript.vbs:</strong></p>
  
  <pre><code>For i=0 To 255
     WScript.StdOut.Write Chr(i)
  Next
  </code></pre>
  
  <p><strong>JScript.js:</strong></p>
  
  <pre><code>for ( var i=0; i &lt;= 255; ++i )
     WScript.StdOut.Write(String.fromCharCode(i));
  </code></pre>
  
  <p>When I execute they in the command-prompt, they show different results:</p>
  
  <pre><code>C:&gt;cscript /nologo VBScript.vbs
   ☺☻♥♦♣
  ♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&amp;'()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]
  ^_`abcdefghijklmnopqrstuvwxyz{|}~⌂??'ƒ".┼╬^%S&lt;O?Z??''""--~Ts&gt;o?zY ¡¢£¤¥¦§¨©ª«¬­®
  ¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ
  ÿ
  
  C:&gt;cscript /nologo JScript.js
   ☺☻♥♦♣
  ♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&amp;'()*+,-./0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]
  ^_`abcdefghijklmnopqrstuvwxyz{|}~⌂???????????????????????????????? ¡¢£¤¥¦§¨©ª«¬­
  ®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüý
  þÿ
  </code></pre>
  
  <p>Previous output may be explained because some operative difference in JScript's fromCharCode method vs. VBScript's Chr function. However, if a try to redirect the output to a disk file, the result is very different:</p>
  
  <pre><code>C:&gt;cscript /nologo VBScript.vbs &gt; VBScript.txt
  
  C:&gt;cscript /nologo JScript.js &gt; JScript.txt
  C:\JScript.js(2, 4) Microsoft JScript runtime error: Invalid procedure call or argument
  
  C:&gt;dir *.txt
  
  15/01/2013  05:48 p.m.               128 JScript.txt
  15/01/2013  05:48 p.m.               256 VBScript.txt
  </code></pre>
  
  <p>In this case, both programs use <em>the same</em> WSH method under <em>the same</em> conditions, so I don't understand why VBS correctly generate the file with 256 characters, but JScript issue an error and just generate the first 128 characters.</p>
  
  <p>What happens here? Is there a way to correctly generate the same file with 256 different characters in JScript? TIA</p>
  
  <p>Antonio</p>