<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; WSH: пример конвертации текста из кодировки в кодировку]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=997</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=997&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «WSH: пример конвертации текста из кодировки в кодировку».]]></description>
		<lastBuildDate>Sun, 12 Jun 2011 20:59:52 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: WSH: пример конвертации текста из кодировки в кодировку]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=49100#p49100</link>
			<description><![CDATA[<p>JScript. Преобразование кодировок cp866 (DOS) и windows-1251<br /></p><div class="codebox"><pre><code>/** Возвращает текст sText преобразованный из кодировки cp866 (DOS) в windows-1251. 
 * Или наоборот - из 1251 в DOS - если флаг bInsideOut равен true.
 */
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>]]></description>
			<author><![CDATA[null@example.com (jite)]]></author>
			<pubDate>Sun, 12 Jun 2011 20:59:52 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=49100#p49100</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: пример конвертации текста из кодировки в кодировку]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=48395#p48395</link>
			<description><![CDATA[<p>JScript. Преобразование кодировки текста в UTF-8<br /></p><div class="codebox"><pre><code>
/** Возвращает текст sText преобразованный из кодировки sSrcCharset (по ум. windows-1251) в UTF-8
 * Обязателен только 1-й параметр 
 */
function sToUTF8(sText, bWithBOM, sSrcCharset) {
  if (!sSrcCharset) sSrcCharset = &quot;windows-1251&quot;; //Для ADODB.Stream default - Unicode. Еще можно KOI8-R, cp866
  sText += &quot;&quot;;
  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 = &quot;utf-8&quot;;
    open();
    writeText(sText);
    position = 0;
    charset = sSrcCharset;
    var nPos = bWithBOM ? 0 : 3;
    return readText().substr(nPos);
  }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (jite)]]></author>
			<pubDate>Sun, 15 May 2011 16:45:28 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=48395#p48395</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: пример конвертации текста из кодировки в кодировку]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=23419#p23419</link>
			<description><![CDATA[<p>Функция перевода текста OEM-866 в Win-1251.<br /></p><div class="codebox"><pre><code>Function D2W(DOS_STRING)
&#039;DOS:
&#039;128(А)-175(п)
&#039;224(р)-239(я)
&#039;240(Ё),241(ё)
&#039;WIN:
&#039;192(А)-255(я)
&#039;184(ё),168(Ё)

If Len(DOS_STRING)=0 Then Exit Function
For i=1 To Len(DOS_STRING)
    s=Asc(Mid(DOS_STRING,i,1))
    If s&gt;=128 And s&lt;=175 Then
       D2W = D2W &amp; Chr(s + 64)
    ElseIf s&gt;=224 And s&lt;=239 Then
       D2W = D2W &amp; Chr(s + 16)
    ElseIf s=240 Then
       D2W = D2W &amp; Chr(168)
    ElseIf s=241 Then
       D2W = D2W &amp; Chr(184)
    Else
       D2W = D2W &amp; Chr(s)
    End If

Next
End Function</code></pre></div><p>Прислал <strong>ingvar68</strong>.</p>]]></description>
			<author><![CDATA[null@example.com (The gray Cardinal)]]></author>
			<pubDate>Thu, 21 May 2009 07:00:43 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=23419#p23419</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: пример конвертации текста из кодировки в кодировку]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=11607#p11607</link>
			<description><![CDATA[<p>Доступные варианты кодировок на компьютере для использования в вышеприведённых скриптах находятся в реестре по адресу HKEY_CLASSES_ROOT\MIME\Database\Charset.</p>]]></description>
			<author><![CDATA[null@example.com (alexii)]]></author>
			<pubDate>Thu, 19 Jun 2008 19:29:29 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=11607#p11607</guid>
		</item>
		<item>
			<title><![CDATA[Re: WSH: пример конвертации текста из кодировки в кодировку]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=7448#p7448</link>
			<description><![CDATA[<p>А это на случай конвертации текста в переменной <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> <img src="//forum.script-coding.com/img/smilies/roll.png" width="15" height="15" /></p><div class="codebox"><pre><code>MsgBox StrConv(&quot;бНОПНЯ&quot;,&quot;KOI8-R&quot;,&quot;Windows-1251&quot;)

Function StrConv(Text,SourceCharset,DestCharset)
    Set Stream = CreateObject(&quot;ADODB.Stream&quot;)
    Stream.Type = 2
    Stream.Mode = 3
    Stream.Open
    Stream.Charset = SourceCharset
    Stream.WriteText Text
    Stream.Position = 0
    Stream.Charset = DestCharset
    StrConv = Stream.ReadText
End Function</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Xameleon)]]></author>
			<pubDate>Fri, 28 Dec 2007 08:50:50 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=7448#p7448</guid>
		</item>
		<item>
			<title><![CDATA[WSH: пример конвертации текста из кодировки в кодировку]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=7364#p7364</link>
			<description><![CDATA[<p>Простейший пример работы с кодировками с помощью ADODB.Stream. Пример преобразует файл C:\Temp\test.txt из UTF-8 в windows-1251:<br /></p><div class="codebox"><pre><code>Set ADODBStream = CreateObject(&quot;ADODB.Stream&quot;)
ADODBStream.Type = 2
ADODBStream.Charset = &quot;UTF-8&quot;
ADODBStream.Open()
ADODBStream.LoadFromFile(&quot;C:\Temp\test.txt&quot;)
Text = ADODBStream.ReadText()
ADODBStream.Close()
ADODBStream.Charset = &quot;windows-1251&quot;
ADODBStream.Open()
ADODBStream.WriteText(Text)
ADODBStream.SaveToFile &quot;C:\Temp\test.txt&quot;, 2
ADODBStream.Close()</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (The gray Cardinal)]]></author>
			<pubDate>Tue, 25 Dec 2007 20:18:12 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=7364#p7364</guid>
		</item>
	</channel>
</rss>
