<?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="http://forum.script-coding.com/extern.php?action=feed&amp;tid=12346&amp;type=atom" />
	<updated>2017-01-22T17:14:13Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=12346</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Замена в тексте английских символов на русские]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=111416#p111416" />
			<content type="html"><![CDATA[<p>Спасибо, все работает.</p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2017-01-22T17:14:13Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=111416#p111416</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Замена в тексте английских символов на русские]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=111395#p111395" />
			<content type="html"><![CDATA[<p>В массиве ключ &quot;A&quot; и &quot;a&quot; одно и тоже.<br /></p><div class="codebox"><pre><code>
#NoEnv
#SingleInstance Force
StringCaseSense, On

oEng := [&quot;A&quot;,&quot;a&quot;,&quot;E&quot;,&quot;e&quot;,&quot;T&quot;,&quot;O&quot;,&quot;o&quot;,&quot;P&quot;,&quot;p&quot;,&quot;H&quot;,&quot;K&quot;,&quot;k&quot;,&quot;X&quot;,&quot;x&quot;,&quot;C&quot;,&quot;c&quot;,&quot;B&quot;,&quot;M&quot;]
oRUS := [&quot;А&quot;,&quot;а&quot;,&quot;Е&quot;,&quot;е&quot;,&quot;Т&quot;,&quot;О&quot;,&quot;о&quot;,&quot;Р&quot;,&quot;р&quot;,&quot;Н&quot;,&quot;К&quot;,&quot;к&quot;,&quot;Х&quot;,&quot;х&quot;,&quot;С&quot;,&quot;с&quot;,&quot;В&quot;,&quot;М&quot;] 

rus := &quot;Растение&quot; ; Слово полностью написано русскими символами
eng := &quot;Pacтeниe&quot; ; Тут буквы &quot;P&quot;, &quot;a&quot;, &quot;c&quot; два &quot;е&quot; написаны анлийскими символами
; Если просто читать то слова одинаковы, но в хексе разные
rush := StringToHex(rus)
engh := StringToHex(eng)
msgbox, rus: %rus%`nHEX rus: %rush%`neng: %eng%`nHEX eng: %engh% ; показывает в хексе символы
 
For k, v in oEng
	StringReplace, eng, eng, % v, % oRUS[k], All 

engh := StringToHex(eng)
msgbox, rus: %rus%`nHEX rus: %rush%`neng: %eng%`nHEX eng: %engh%
; видно что заменятся и хекс одинаковый, кроме первой буквы. Первая буква становится маленькой

StringToHex(String)
	{
	local Old_A_FormatInteger, CharHex, HexString
	
	;Return &#039;0&#039; if the string was blank
	If !String
		Return 0
	
	;Save the current Integer format
	Old_A_FormatInteger := A_FormatInteger
	
	;Set the format of integers to their Hex value
	SetFormat, INTEGER, H
	
	;Parse the String
	Loop, Parse, String 
		{
		;Get the ASCII value of the Character (will be converted to the Hex value by the SetFormat Line above)
		CharHex := Asc(A_LoopField)
	
		;Comment out the following line to leave the &#039;0x&#039; intact
		StringTrimLeft, CharHex, CharHex, 2
		
		;Build the return string
		HexString .= CharHex . &quot; &quot;
		}
	;Set the integer format to what is was prior to the call
	SetFormat, INTEGER, %Old_A_FormatInteger%
	
	;Return the string to the caller
	Return HexString
	}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-01-22T08:32:56Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=111395#p111395</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Замена в тексте английских символов на русские]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=111392#p111392" />
			<content type="html"><![CDATA[<p>Не понимаю, вставил учет регистра и все равно большую заменяет на маленькую.<br /></p><div class="codebox"><pre><code>StringCaseSense, on</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2017-01-22T08:11:29Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=111392#p111392</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Замена в тексте английских символов на русские]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=111387#p111387" />
			<content type="html"><![CDATA[<p><span style="color: green"><strong>Dworkin</strong><br />Отредактируйте заголовок, добавьте отсутствующие точки.</span></p><p><span style="color: green"><strong>Принято</strong>. Заголовок приближен к ТЗ.</span></p>]]></content>
			<author>
				<name><![CDATA[Flasher]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27593</uri>
			</author>
			<updated>2017-01-22T07:05:00Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=111387#p111387</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Замена в тексте английских символов на русские]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=111386#p111386" />
			<content type="html"><![CDATA[<p>Помогите пожалуйста.<br />Нашел как заменять английские символы на русские, НО происходит какой-то баг.<br />Заменяет все символы хорошо, кроме первого большого символа, он ее заменяет на маленькую русскую букву почему-то. Короче заменяет все большие символы на маленькие.<br />В HEX&#039;e:<br />английская P = 50 <br />английская p = 70<br />русская P = D0<br />русская p = F0<br />То есть по хексу первая буква была 50(БОЛЬШАЯ англ P), а стала после замены F0(маленькая рус Р).</p><p>То есть:<br /></p><div class="codebox"><pre><code>
rus := &quot;Растение&quot; ; Слово полностью написано русскими символами
eng := &quot;Pacтeниe&quot; ; Тут буквы &quot;P&quot;, &quot;a&quot;, &quot;c&quot; два &quot;е&quot; написаны анлийскими символами
; Если просто читать то слова одинаковы, но в хексе разные
rush := StringToHex(rus)
engh := StringToHex(eng)
msgbox, rus: %rus%`nHEX rus: %rush%`neng: %eng%`nHEX eng: %engh% ; показывает в хексе символы

for s, r in {A:&quot;А&quot;, a:&quot;а&quot;, E:&quot;Е&quot;, e:&quot;е&quot;, T:&quot;Т&quot;, O:&quot;О&quot;, o:&quot;о&quot;, P:&quot;Р&quot;, p:&quot;р&quot;, H:&quot;Н&quot;, K:&quot;К&quot;, k:&quot;к&quot;, X:&quot;Х&quot;, x:&quot;х&quot;, C:&quot;С&quot;, c:&quot;с&quot;, B:&quot;В&quot;, M:&quot;М&quot;} ; слева символ на английском, справа после двоеточия на русском

StringReplace, eng, eng, % s, % r, All ; делает замену
engh := StringToHex(eng)
msgbox, rus: %rus%`nHEX rus: %rush%`neng: %eng%`nHEX eng: %engh%
; видно что заменятся и хекс одинаковый, кроме первой буквы. Первая буква становится маленькой

StringToHex(String)
	{
	local Old_A_FormatInteger, CharHex, HexString
	
	;Return &#039;0&#039; if the string was blank
	If !String
		Return 0
	
	;Save the current Integer format
	Old_A_FormatInteger := A_FormatInteger
	
	;Set the format of integers to their Hex value
	SetFormat, INTEGER, H
	
	;Parse the String
	Loop, Parse, String 
		{
		;Get the ASCII value of the Character (will be converted to the Hex value by the SetFormat Line above)
		CharHex := Asc(A_LoopField)
	
		;Comment out the following line to leave the &#039;0x&#039; intact
		StringTrimLeft, CharHex, CharHex, 2
		
		;Build the return string
		HexString .= CharHex . &quot; &quot;
		}
	;Set the integer format to what is was prior to the call
	SetFormat, INTEGER, %Old_A_FormatInteger%
	
	;Return the string to the caller
	Return HexString
	}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2017-01-22T06:29:13Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=111386#p111386</id>
		</entry>
</feed>
