<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; JScript: Функция преобразования в UTF-8]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=5793&amp;type=atom" />
	<updated>2011-05-14T18:17:25Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=5793</id>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Функция преобразования в UTF-8]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=48375#p48375" />
			<content type="html"><![CDATA[<p>Если по функции вопросов нет, тогда давайте откроем тему по распознаванию кодировки.</p>]]></content>
			<author>
				<name><![CDATA[jite]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25851</uri>
			</author>
			<updated>2011-05-14T18:17:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=48375#p48375</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Функция преобразования в UTF-8]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=48353#p48353" />
			<content type="html"><![CDATA[<p><strong>Slav</strong>, может брать каждую пару байт и проверять их на вхождение в алфавит? То есть берем пару байт, рассматриваем их в качестве UTF8, если входит в «алфавит», то переходим к следующей паре. Если нет, то проверяем на однобайтовые кодировки.</p>]]></content>
			<author>
				<name><![CDATA[JSmаn]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24434</uri>
			</author>
			<updated>2011-05-13T17:22:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=48353#p48353</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Функция преобразования в UTF-8]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=48341#p48341" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>JSman пишет:</cite><blockquote><p>Лучше алгоритм распознавания кодировки частей текста написать:) - это может пригодиться при изучении протокола аськи да и других вещей.</p></blockquote></div><p>Поддерживаю.<br />Вещь актуальная и очень нужная - добавлю получение писем в непонятной кодировке, &quot;да и другие вещи&quot;.</p><p>Было бы удобно: скопировал текст &quot;с кракозяблами&quot; в буфер, запустил скрипт, на выходе читабельное содержимое.<br />В качестве аналога приведу давно известную прогу &quot;Штирлиц&quot;.</p>]]></content>
			<author>
				<name><![CDATA[Slav]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=16491</uri>
			</author>
			<updated>2011-05-13T05:20:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=48341#p48341</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Функция преобразования в UTF-8]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=48340#p48340" />
			<content type="html"><![CDATA[<p>Лучше алгоритм распознавания кодировки частей текста написать:) - это может пригодиться при изучении протокола аськи да и других вещей.</p>]]></content>
			<author>
				<name><![CDATA[JSmаn]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24434</uri>
			</author>
			<updated>2011-05-12T19:17:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=48340#p48340</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Функция преобразования в UTF-8]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=48337#p48337" />
			<content type="html"><![CDATA[<p>Туда - после предварительного рассмотрения здесь. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[jite]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25851</uri>
			</author>
			<updated>2011-05-12T17:13:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=48337#p48337</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: JScript: Функция преобразования в UTF-8]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=48323#p48323" />
			<content type="html"><![CDATA[<p><strong>2 jite:</strong> А чего не в коллекцию сразу ? <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br /><a href="http://forum.script-coding.com/viewtopic.php?id=997">http://forum.script-coding.com/viewtopic.php?id=997</a><br />Вполне актуально вроде бы ?</p>]]></content>
			<author>
				<name><![CDATA[Xameleon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=8836</uri>
			</author>
			<updated>2011-05-12T07:52:40Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=48323#p48323</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[JScript: Функция преобразования в UTF-8]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=48318#p48318" />
			<content type="html"><![CDATA[<p>Как бы баян, но на JScript чего-то не попадалось такого. Выложу до кучи, вдруг кто чего дополнит.<br /></p><div class="codebox"><pre><code>/** Возвращает текст sText преобразованный из кодировки srcCharset (по ум. windows-1251) в UTF-8
 * Обязателен только 1-й параметр 
 */
function sToUTF8(sText, bWithBOM, srcCharset) {
  if (!srcCharset) srcCharset = &quot;windows-1251&quot;; //Для ADODB.Stream default - Unicode. Еще можно KOI8-R, cp866
  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 = srcCharset;
    var nPos = bWithBOM ? 0 : 3;
    return readText().substr(nPos);
  }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[jite]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25851</uri>
			</author>
			<updated>2011-05-11T21:57:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=48318#p48318</id>
		</entry>
</feed>
