<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; JS: символы русского алфавита из WScript.StdIn.ReadLine()]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13200&amp;type=atom" />
	<updated>2017-11-14T17:35:37Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13200</id>
		<entry>
			<title type="html"><![CDATA[Re: JS: символы русского алфавита из WScript.StdIn.ReadLine()]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=121158#p121158" />
			<content type="html"><![CDATA[<p>За первый вариант прошу прощения - я его из под Far-а запускал, там он всё на русском и на экран выводил и в файл писал. Из консоли я его не проверил, там всё действительно плохо.</p>]]></content>
			<author>
				<name><![CDATA[Spy00000]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27060</uri>
			</author>
			<updated>2017-11-14T17:35:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=121158#p121158</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JS: символы русского алфавита из WScript.StdIn.ReadLine()]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=121157#p121157" />
			<content type="html"><![CDATA[<p><strong>Spy00000</strong><br />Первый пример не вариант, не видно что вводишь на русском, а второй отлично работает! Спасибо большое <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[im2002]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28063</uri>
			</author>
			<updated>2017-11-14T17:10:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=121157#p121157</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JS: символы русского алфавита из WScript.StdIn.ReadLine()]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=121156#p121156" />
			<content type="html"><![CDATA[<p>Первый вариант - запускать из батника примерно такого вида (условно примем, что js скрипт сохранён в файл 1.js):<br /></p><div class="codebox"><pre><code>
chcp 1251
cscript 1.js
</code></pre></div><p>и дальше как вариант развития - собирать это в один файл bat + js. </p><br /><p>Второй вариант (код sDOS2Win взят из <a href="http://forum.script-coding.com/viewtopic.php?pid=49100#p49100">WSH: пример конвертации текста из кодировки в кодировку</a>):<br /></p><div class="codebox"><pre><code>
WScript.StdOut.WriteLine(&quot;Введите имя пользователя&quot;);
var Usr = WScript.StdIn.ReadLine();
Usr = sDOS2Win( Usr, false );
var fso = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;);
var TextStream = fso.OpenTextFile(&quot;rezult.txt&quot;, 8, true, -1);                                                   // параметры &quot;0&quot; и &quot;-2&quot; также пробовал
TextStream.WriteLine(&quot;ФИО пользователя: &quot; + Usr);


function sDOS2Win(sText, bInsideOut) {
  var aCharsets = [&quot;windows-1251&quot;, &quot;cp866&quot;];
  sText += &quot;&quot;;
  bInsideOut = bInsideOut ? 1 : 0;
  with (new ActiveXObject(&quot;ADODB.Stream&quot;)) { //http://www.w3schools.com/ado/ado_ref_stream.asp
    type = 2; //Binary 1, Text 2 (default) 
    mode = 3; //Permissions have not been set 0,  Read-only 1,  Write-only 2,  Read-write 3,  
    //Prevent other read 4,  Prevent other write 8,  Prevent other open 12,  Allow others all 16
    charset = aCharsets[bInsideOut];
    open();
    writeText(sText);
    position = 0;
    charset = aCharsets[1 - bInsideOut];
    return readText();
  }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Spy00000]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27060</uri>
			</author>
			<updated>2017-11-14T16:59:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=121156#p121156</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[JS: символы русского алфавита из WScript.StdIn.ReadLine()]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=121152#p121152" />
			<content type="html"><![CDATA[<p>Подскажите, есть ли возможность увидеть в файле &quot;rezult.txt&quot; русские буквы? Скрипт запускается на сервере сценариев cscript.exe</p><div class="codebox"><pre><code>WScript.StdOut.WriteLine(&quot;Введите имя пользователя&quot;);
var Usr = WScript.StdIn.ReadLine();
var fso = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;);
var TextStream = fso.OpenTextFile(&quot;rezult.txt&quot;, 8, true, -1);							// параметры &quot;0&quot; и &quot;-2&quot; также пробовал
TextStream.WriteLine(&quot;ФИО пользователя: &quot; + Usr);</code></pre></div>]]></content>
			<author>
				<name><![CDATA[im2002]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28063</uri>
			</author>
			<updated>2017-11-14T15:04:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=121152#p121152</id>
		</entry>
</feed>
