<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Кириллица в URL]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=10161</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=10161&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Кириллица в URL».]]></description>
		<lastBuildDate>Sun, 23 Aug 2015 23:38:16 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=96788#p96788</link>
			<description><![CDATA[<p>Одинаково:<br /></p><div class="codebox"><pre><code>SetFormat, IntegerFast, H
str := &quot;ЁЁ&quot;
MsgBox, % NumGet(str, &quot;UInt&quot;)
While code := NumGet(str, A_Index - 1, &quot;UChar&quot;)
    MsgBox, % code

VarSetCapacity(var, StrPut(str, &quot;UTF-8&quot;))
StrPut(str, &amp;var, &quot;UTF-8&quot;)
MsgBox, % NumGet(var, &quot;UInt&quot;)

While code := NumGet(var, A_Index - 1, &quot;UChar&quot;)
    MsgBox, % code</code></pre></div><p>В UTF-8 Ё — 0x81D0, a в URL — в обратном порядке: %D0%81</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 23 Aug 2015 23:38:16 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=96788#p96788</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=96787#p96787</link>
			<description><![CDATA[<p>Туго у меня с этим делом... Например почему в случае с &quot;перебором&quot; байтов в &quot;UTF-8&quot; всё по порядку?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sun, 23 Aug 2015 23:31:53 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=96787#p96787</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=96784#p96784</link>
			<description><![CDATA[<p>Чтение идёт от младших байтов к старшим.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 23 Aug 2015 23:27:07 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=96784#p96784</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=96783#p96783</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>0x1 — это 0x01<br />0x4 — это 0x04<br />Вместе 0x0401</p></blockquote></div><p>Жутко не понятно, почему не по порядку - 0x0104.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sun, 23 Aug 2015 23:25:10 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=96783#p96783</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=96782#p96782</link>
			<description><![CDATA[<p>А, ну да, может быть и четыре для всяких символов типа арабских. В AHK-Unicode строки кодируются в UTF-16, так что </p><div class="codebox"><pre><code>encoding := &quot;UTF-16&quot; 
VarSetCapacity(var, StrPut(str, encoding))
StrPut(str, &amp;var, encoding) </code></pre></div><p>не нужно.<br /></p><div class="codebox"><pre><code>SetFormat, IntegerFast, H
str := &quot;Ё&quot; 

While code := NumGet(str, A_Index - 1, &quot;UChar&quot;)
    MsgBox, % code</code></pre></div><p>0x1 — это 0x01<br />0x4 — это 0x04<br />Вместе 0x0401</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 23 Aug 2015 23:22:22 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=96782#p96782</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=96781#p96781</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>UTF-16 — 2 байта на символ (16 бит).</p></blockquote></div><p>Но может быть и 4?<br /></p><div class="quotebox"><cite>wikipedia пишет:</cite><blockquote><p>Один символ кодировки UTF-16 представлен последовательностью двух байтов или <span class="bbu">двух пар байтов</span></p></blockquote></div><p>Ещё меньше понимаю что за 1 потом 4 в этом коде:<br /></p><div class="codebox"><pre><code>SetFormat, IntegerFast, H
str := &quot;Ё&quot; 
encoding := &quot;UTF-16&quot; 
VarSetCapacity(var, StrPut(str, encoding))
StrPut(str, &amp;var, encoding) 
While code := NumGet(Var, A_Index - 1, &quot;UChar&quot;)
    MsgBox, % code</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sun, 23 Aug 2015 23:08:41 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=96781#p96781</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=96780#p96780</link>
			<description><![CDATA[<div class="codebox"><pre><code>SetFormat, IntegerFast, H
str := &quot;ЁЁ&quot;
VarSetCapacity(var, StrPut(str, &quot;UTF-8&quot;))
StrPut(str, &amp;var, &quot;UTF-8&quot;)
MsgBox, % NumGet(var, &quot;UInt&quot;)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 23 Aug 2015 22:56:59 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=96780#p96780</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=96779#p96779</link>
			<description><![CDATA[<p>UTF-16 — 2 байта на символ (16 бит).<br /></p><div class="codebox"><pre><code>SetFormat, IntegerFast, H
str := &quot;ЁЁ&quot;
MsgBox, % NumGet(&amp;str, &quot;UInt&quot;)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 23 Aug 2015 22:43:55 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=96779#p96779</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=96777#p96777</link>
			<description><![CDATA[<p>Теперь ещё более непонятно, 0xD0 и 0x81 это цифровое представление двух байт в UTF-8.?<br />А какая связь 0x401 и UTF-16?&nbsp; В UTF-16 кажется 4 байта на символ, да и 0x401 не может быть представлением байта.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sun, 23 Aug 2015 22:24:29 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=96777#p96777</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=96775#p96775</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>С первым MsgBox понятно, а во втором число 0x401 как то логично &quot;разбивается&quot; на 0xd0 &amp; 0x81?</p></blockquote></div><p>Ё = 0x401 — это UTF-16, а %D0%81 — это UTF-8.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 23 Aug 2015 22:10:51 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=96775#p96775</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=96768#p96768</link>
			<description><![CDATA[<p>Пара вопросов.<br />Сократил запись (хлебом не корми):<br /></p><div class="codebox"><pre><code>
URIEncode(str, encoding := &quot;UTF-8&quot;) {  
    VarSetCapacity(var, StrPut(str, encoding)), StrPut(str, &amp;var, encoding) 
    While code := NumGet(Var, A_Index - 1, &quot;UChar&quot;)
        UrlStr .= (code &gt; 0x7F || code &lt; 0x30 || code = 0x3D) ? Format(&quot;%{:02X}&quot;, code) : Chr(code) 
    Return UrlStr
}
</code></pre></div><p>Есть ли ошибки, и смущает расхождение с оригиналом:<br /></p><div class="codebox"><pre><code>SubStr(&quot;0&quot; . SubStr(code, 3), -1)</code></pre></div><p> <br />После процента обязательно должно быть 2 знака?</p><p>И для общего развития, по поводу индекса в Unicode и значений байтов (собственно а есть ли тут связь?).<br /></p><div class="codebox"><pre><code>SetFormat, IntegerFast, h
 ; в комментариях значения как и в NumGet
str :=  &quot;,&quot;  
MsgBox, % Ord(str) ; 0x2c

str :=  &quot;Ё&quot; 
MsgBox, % Ord(str) ; 0xd0 &amp; 0x81</code></pre></div><p>С первым MsgBox понятно, а во втором число 0x401 как то логично &quot;разбивается&quot; на 0xd0 &amp; 0x81?</p><p>Ап: По поводу: </p><div class="quotebox"><blockquote><p>После процента обязательно должно быть 2 знака?</p></blockquote></div><p>Разобрался, поправил.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Sun, 23 Aug 2015 18:55:17 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=96768#p96768</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=88474#p88474</link>
			<description><![CDATA[<p>Немного сократил:<br /></p><div class="codebox"><pre><code>text := &quot;&quot;&quot;кодировка URL&quot;&quot;&quot;
GoogleSearch := &quot;https://www.google.ru/search?q=&quot;

MsgBox, % url := GoogleSearch . URIEncode(text)
Run, % url

URIEncode(str, encoding := &quot;UTF-8&quot;)
{
   PrevFormat := A_FormatInteger
   SetFormat, IntegerFast, H
; кодируем стоку в указанную кодировку с помощью StrPut()
   VarSetCapacity(var, StrPut(str, encoding))
   StrPut(str, &amp;var, encoding)
; последовательно перебирая символы, кодируем их в URL-формат   
   While code := NumGet(Var, A_Index - 1, &quot;UChar&quot;)   ; пока code не равно 0, что означает конец строки
   {
      bool := (code &gt; 0x7F || code &lt; 0x30 || code = 0x3D)   ; отсеиваем символы, которые кодировать не нужно
      UrlStr .= bool ? &quot;%&quot; . SubStr(&quot;0&quot; . SubStr(code, 3), -1) : Chr(code)
   }
   SetFormat, IntegerFast, % PrevFormat
   Return UrlStr
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 19 Nov 2014 20:18:38 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=88474#p88474</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=88469#p88469</link>
			<description><![CDATA[<p>Тоже не понял в каких случаях, но если пример универсален, то поддерживаю, надо в коллекцию.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 19 Nov 2014 17:09:40 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=88469#p88469</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=88467#p88467</link>
			<description><![CDATA[<p>Можно, хотя я так и не понял, в каких конкретно случаях требуется конвертировать в ANSI.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 19 Nov 2014 17:02:11 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=88467#p88467</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Кириллица в URL]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=88455#p88455</link>
			<description><![CDATA[<p>Предлагаю пример в Коллекцию. Это становится актуально.</p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Wed, 19 Nov 2014 09:47:34 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=88455#p88455</guid>
		</item>
	</channel>
</rss>
