<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Смена кодировки текста в переменной]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=10446&amp;type=atom" />
	<updated>2015-02-24T08:43:10Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=10446</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Смена кодировки текста в переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91884#p91884" />
			<content type="html"><![CDATA[<p>В Юникоде код символа — это два байта, т.е. в хексе будет 4 символа. С поправкой на это, вроде всё работает.<br /></p><div class="codebox"><pre><code>
StrToHex = Привет Мир!

StrtoHex:
SetFormat, Integer, H
CodeString =
Loop, Parse, StrToHex
{
  CharCode := Asc(A_LoopField)
  CodeString .= SubStr(&quot;000&quot; . SubStr(CharCode, 3), -3)
}
StringUpper, CodeString, CodeString
MsgBox %CodeString%



HextoStr:
HextoStr = %CodeString%
Text =
Pos = 1
Loop, % StrLen(HextoStr) // 4
{
  CharCode := &quot;0x&quot; . SubStr(HextoStr, Pos, 4)
  Text .= Chr(CharCode)
  Pos += 4
}
MsgBox %Text%
return
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-02-24T08:43:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91884#p91884</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Смена кодировки текста в переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91882#p91882" />
			<content type="html"><![CDATA[<p>Может и в UTF-16.<br />Я&nbsp; не особо понимаю как эти функции использовать: StrGet и StrPut.<br />Проблема возникает в этом скрипте, который переводит строку в HEX и обратно HEX в строку.<br />Раньше на версии AutoHotkey ANSI все работало отлично, а теперь на выходе бяки.<br /></p><div class="codebox"><pre><code>StrToHex = Привет Мир!

StrtoHex:
SetFormat, Integer, H
CodeString =
Loop, Parse, StrToHex
{
  CharCode := Asc(A_LoopField)
  If CharCode &lt; 0x10
    CodeString .= &quot;0&quot; . SubStr(CharCode, 3)
  Else
    CodeString .= SubStr(CharCode, 3)
}
StringUpper, CodeString, CodeString
MsgBox %CodeString%



HextoStr:
HextoStr = %CodeString%
Text =
Pos = 1
Loop, % StrLen(HextoStr) / 2
{
  CharCode := &quot;0x&quot; . SubStr(HextoStr, Pos, 2)
  Text .= Chr(CharCode)
  Pos += 2
}
MsgBox %Text%
return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[avens]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24487</uri>
			</author>
			<updated>2015-02-24T08:12:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91882#p91882</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Смена кодировки текста в переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91869#p91869" />
			<content type="html"><![CDATA[<p>А вы уверены, что он там именно в UTF-8? Родная кодировка для строк в юникодном АНК —&nbsp; UTF-16. Но если таки да, т.е. переменная используется просто как буфер, то сначала прочитать StrGet как UTF-8, потом записать StrPut как ANSI. Или наоборот.</p><p>Учесть размер буфера, чтобы не вылезти за его пределы (во втором случае).</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-02-23T18:34:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91869#p91869</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Смена кодировки текста в переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=91861#p91861" />
			<content type="html"><![CDATA[<p>Необходимо сменить кодировку текста в переменной с UTF-8 в ANSI и обратно.<br />Как это делается?<br />Рабочая версия AutoHotkey Unicode</p>]]></content>
			<author>
				<name><![CDATA[avens]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24487</uri>
			</author>
			<updated>2015-02-23T17:22:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=91861#p91861</id>
		</entry>
</feed>
