<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Перевод из hex в текст английский+русский]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=12240&amp;type=atom" />
	<updated>2016-12-22T01:09:14Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=12240</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перевод из hex в текст английский+русский]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=110000#p110000" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>HexData := &quot;31 00 2d 00 45 00 6e 00 67 00 6c 00 69 00 73 00 68 00 00 00 32 00 2d 00 20 04 43 04 41 04 41 04 3a 04 38 04 39 04 00 00 00 00&quot;

for k, v in Hex2Text(HexData)
   MsgBox, % v

Hex2Text(hex)  {
   VarSetCapacity(str, StrLen(hex := StrReplace(hex, &quot; &quot;))//2, 0)
   pStrings := [&amp;str]
   
   while RegExMatch(hex, &quot;O)(..)(..)&quot;, match, A_Index = 1 ? 1 : match.Pos(0) + 4)  {
      h := &quot;0x&quot; . match[2] . match[1]
      NumPut(h, (addr := &amp;str + (A_Index - 1)*2) + 0)
      (endOfStr &amp;&amp; h != 0 &amp;&amp; pStrings.Push(addr) &amp;&amp; endOfStr := &quot;&quot;)
      (h = 0 &amp;&amp; endOfStr := 1)
   }
   
   for k, v in pStrings
      pStrings[k] := StrGet(v, &quot;UTF-16&quot;)
   Return pStrings
}</code></pre></div><p>По идее, должно в любом случае сработать. Должны появиться два сообщения, так как здесь две строки, разделённые двухбайтным нулём.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-12-22T01:09:14Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=110000#p110000</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перевод из hex в текст английский+русский]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=109999#p109999" />
			<content type="html"><![CDATA[<p><strong>Mambr</strong><br />Используйте AutoHotkey Unicode.</p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2016-12-22T01:03:15Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=109999#p109999</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перевод из hex в текст английский+русский]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=109998#p109998" />
			<content type="html"><![CDATA[<p>А как выглядит последний вариант?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-12-22T00:29:44Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=109998#p109998</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перевод из hex в текст английский+русский]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=109996#p109996" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, а у меня оба варианта - вообще глухарь.<br />Сейчас ищу вариант, может задействовать в раскодировании какую-нить стороннюю dll ...</p>]]></content>
			<author>
				<name><![CDATA[Mambr]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34398</uri>
			</author>
			<updated>2016-12-21T23:51:42Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=109996#p109996</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перевод из hex в текст английский+русский]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=109994#p109994" />
			<content type="html"><![CDATA[<p>Не, ну так совсем плохо.</p><div class="codebox"><pre><code>HexData := &quot;31 00 2d 00 45 00 6e 00 67 00 6c 00 69 00 73 00 68 20 00 32 00 2d 00 20 04 43 04 41 04 41 04 3a 04 38 04 39 04&quot;

MsgBox, % Hex2Text(HexData)

Hex2Text(hex)  {
   Loop parse, hex, % A_Space
   {
      if mod(A_Index, 2)
         num := A_LoopField
      else
         str .= Chr(&quot;0x&quot; . A_LoopField . num)
   }
	Return str
}</code></pre></div><p>А вот из предыдущего примера получается:<br /></p><div class="codebox"><pre><code>HexData =
(
31 00 2d 00 45 00 6e 00 67 00 6c 00 69 00 73 00 68 00 00 00 32 00 2d 00 20 04 43 04 41 04 41 04 3a 04 38 04 39 04 00 00 00 00
)

MsgBox, % Hex2Text(HexData)

Hex2Text(hex)  {
   Loop parse, hex, % A_Space
   {
      if mod(A_Index, 2)
         num := A_LoopField
      else
         str .= Chr(&quot;0x&quot; . A_LoopField . num)
   }
   Return str
}</code></pre></div><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Наверно, закодировать правильно нужно</p></blockquote></div><p>Оказалось, раскодировать. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> В каждом символе два байта, это юникод.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-12-21T22:37:36Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=109994#p109994</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перевод из hex в текст английский+русский]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=109991#p109991" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, кодировал не я, а программа. Я лишь пытаюсь перекодировать ... пока безуспешно.</p><p>Чтобы не было лишних вопросов, сделаем так:</p><div class="codebox"><pre><code>HexData := &quot;31 00 2d 00 45 00 6e 00 67 00 6c 00 69 00 73 00 68 20 00 32 00 2d 00 20 04 43 04 41 04 41 04 3a 04 38 04 39 04&quot;

Loop parse, HexData, % A_Space
	{
	Txt .= Chr(&quot;0x&quot; A_LoopField)
	}
	
MsgBox % Txt</code></pre></div><p>Скажем, надо перевести все в читабельный текст ...</p>]]></content>
			<author>
				<name><![CDATA[Mambr]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34398</uri>
			</author>
			<updated>2016-12-21T21:40:52Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=109991#p109991</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перевод из hex в текст английский+русский]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=109990#p109990" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>MandarinKa02 пишет:</cite><blockquote><p>в ANSI нет поддержки русских символов.</p></blockquote></div><p>Чё это <a href="https://ru.wikipedia.org/wiki/%D0%9A%D0%BE%D0%B4%D0%BE%D0%B2%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0#.D0.92_.D1.81.D0.B8.D1.81.D1.82.D0.B5.D0.BC.D0.B5_Microsoft_Windows">нет</a>?<br /></p><div class="quotebox"><cite>Mambr пишет:</cite><blockquote><p>Есть ли решение этого вопроса?</p></blockquote></div><p>Наверно, закодировать правильно нужно. Код символа получить так можно:<br /></p><div class="codebox"><pre><code>MsgBox, % Asc(&quot;Я&quot;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-12-21T21:24:14Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=109990#p109990</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Перевод из hex в текст английский+русский]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=109981#p109981" />
			<content type="html"><![CDATA[<p>Насколько я знаю ASCII это фундамент ANSI, а в ANSI нет поддержки русских символов.</p>]]></content>
			<author>
				<name><![CDATA[MandarinKa02]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34409</uri>
			</author>
			<updated>2016-12-21T19:46:51Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=109981#p109981</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Перевод из hex в текст английский+русский]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=109979#p109979" />
			<content type="html"><![CDATA[<p>Добрый день!</p><p>Нужно сделать перевод из hex в текст, содержащий английские и русские слова.<br />Элементарный код дает на выхлопе кракозябры вместо русского, но английский идет нормально.</p><p>Пример строки hex-данных, содержащей английский и русский:<br /></p><div class="codebox"><pre><code>HexData =
(
31 00 2d 00 45 00 6e 00 67 00 6c 00 69 00 73 00 68 00 00 00 32 00 2d 00 20 04 43 04 41 04 41 04 3a 04 38 04 39 04 00 00 00 00
)

Loop parse, HexData, % A_Space
	{
	ASCII .= Chr(&quot;0x&quot; A_LoopField)
	}
	
MsgBox % ASCII</code></pre></div><p>Есть ли решение этого вопроса?</p>]]></content>
			<author>
				<name><![CDATA[Mambr]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34398</uri>
			</author>
			<updated>2016-12-21T19:29:55Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=109979#p109979</id>
		</entry>
</feed>
