<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Проблемы с кодировкой при HTTP запросе.]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=14491&amp;type=atom" />
	<updated>2019-01-15T07:46:44Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=14491</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблемы с кодировкой при HTTP запросе.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131223#p131223" />
			<content type="html"><![CDATA[<p><strong>wisgest</strong>, мне кажется, что ваш вариант неправильный.<br />Вы получаете массив байтов, а записываете его как текст.<br />Правильно делать как-то так:<br /></p><div class="codebox"><pre><code>whr := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
whr.Open(&quot;GET&quot;, &quot;http://185.228.233.140:7777/?method=message.get&amp;login=Randewoo&amp;message_id=1&quot;, false)
whr.Send()

ADODBStream := ComObjCreate(&quot;ADODB.Stream&quot;)
ADODBStream.Type := 1 ; Binary data
ADODBStream.Mode  := 3 ;adModeReadWrite
ADODBStream.Open()
ADODBStream.Write(whr.ResponseBody)
ADODBStream.Position := 0
ADODBStream.Type := 2 ;adTypeText
ADODBStream.Charset := &quot;UTF-8&quot;

MsgBox, % ADODBStream.ReadText()
ADODBStream.Close()</code></pre></div><p>Хотя зачем использовать вообще ADODBStream, когда можно взять напрямую из памяти?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-01-15T07:46:44Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131223#p131223</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблемы с кодировкой при HTTP запросе.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131219#p131219" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, а у меня их нет.<br />Попробовал </p><div class="codebox"><pre><code>MsgBox, % Substr(ADODBStream.ReadText(), 3)</code></pre></div><p> — начинается сразу с «response&quot;{&quot;code&quot;:503,…».</p>]]></content>
			<author>
				<name><![CDATA[wisgest]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=3850</uri>
			</author>
			<updated>2019-01-15T05:37:10Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131219#p131219</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблемы с кодировкой при HTTP запросе.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131215#p131215" />
			<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>2019-01-14T21:31:08Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131215#p131215</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблемы с кодировкой при HTTP запросе.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131212#p131212" />
			<content type="html"><![CDATA[<p>BOM</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2019-01-14T21:17:38Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131212#p131212</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблемы с кодировкой при HTTP запросе.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131206#p131206" />
			<content type="html"><![CDATA[<p><strong>wisgest</strong>, ваш почему-то выдаёт два нечитаемых знака в начале текста:</p><p><span class="postimg"><img src="https://i.imgur.com/1GQillS.png" alt="https://i.imgur.com/1GQillS.png" /></span></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-01-14T18:57:39Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131206#p131206</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблемы с кодировкой при HTTP запросе.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131200#p131200" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, <strong>wisgest</strong>, большое Вам спасибо. Все работает!</p>]]></content>
			<author>
				<name><![CDATA[Finx]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34499</uri>
			</author>
			<updated>2019-01-14T17:45:18Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131200#p131200</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблемы с кодировкой при HTTP запросе.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131196#p131196" />
			<content type="html"><![CDATA[<p>Вот ещё на всякий случай <a href="http://forum.script-coding.com/viewtopic.php?pid=7448#p7448">способ</a>:<br /></p><div class="codebox"><pre><code>whr := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
whr.Open(&quot;GET&quot;, &quot;http://185.228.233.140:7777/?method=message.get&amp;login=Randewoo&amp;message_id=1&quot;, false)
whr.Send()

ADODBStream := ComObjCreate(&quot;ADODB.Stream&quot;)
ADODBStream.Type := 2 ;adTypeText
ADODBStream.Mode  := 3 ;adModeReadWrite
ADODBStream.Open()
;ADODBStream.Charset := &quot;UTF-16&quot;
ADODBStream.WriteText(whr.ResponseBody)
ADODBStream.Position := 0
ADODBStream.Charset := &quot;UTF-8&quot;

MsgBox, % ADODBStream.ReadText()
ADODBStream.Close()
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[wisgest]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=3850</uri>
			</author>
			<updated>2019-01-14T15:18:22Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131196#p131196</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблемы с кодировкой при HTTP запросе.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131194#p131194" />
			<content type="html"><![CDATA[<p>Возможные варианты:<br /></p><div class="codebox"><pre><code>url := &quot;http://185.228.233.140:7777/?method=message.get&amp;login=Randewoo&amp;message_id=1&quot;
whr := ComObjCreate(&quot;Microsoft.XmlHttp&quot;)
whr.Open(&quot;GET&quot;, url, false)
whr.Send()
MsgBox, % whr.ResponseText</code></pre></div><div class="codebox"><pre><code>url := &quot;http://185.228.233.140:7777/?method=message.get&amp;login=Randewoo&amp;message_id=1&quot;
whr := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
whr.Open(&quot;GET&quot;, url, false)
whr.Send()
body := whr.responseBody
pdata := NumGet(ComObjValue(body) + 8 + A_PtrSize)
length := body.MaxIndex() - body.MinIndex() + 1
MsgBox, % text := StrGet(pdata, length, &quot;utf-8&quot;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-01-14T14:09:14Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131194#p131194</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Проблемы с кодировкой при HTTP запросе.]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131191#p131191" />
			<content type="html"><![CDATA[<p>Привет.<br />Собственно, проблема в том, что я не могу получить корректный текст (кириллицу) из HTTP запроса.<br />Вот сам запрос:</p><div class="codebox"><pre><code>http://185.228.233.140:7777/?method=message.get&amp;login=Randewoo&amp;message_id=1</code></pre></div><p>В браузере (по крайней мере - у меня) все отлично работает, кириллица корректно отображается.<br />Но когда я делаю этот-же запрос, но через AHK, у меня выводит следующее вот это - <a href="http://prntscr.com/m6zg9m">http://prntscr.com/m6zg9m</a><br />Я указывал разные заголовки, которые указаны в браузере. Но ничего не сработало.<br />Вот сам код:<br /></p><div class="codebox"><pre><code>
execute(array) {
		whr := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
		whr.Open(&quot;GET&quot;, this.scheme &quot;://&quot; this.domain this.build_http_array(array), true)
		whr.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/json;q=0.9,*/*;q=0.8&quot;)
		whr.SetRequestHeader(&quot;Accept-Language&quot;, &quot;ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3&quot;)
		whr.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 10.0; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0&quot;)
		whr.Send()
		whr.WaitForResponse()
		FileAppend, % whr.ResponseText
		, % A_MyDocuments &quot;\requests_log.txt&quot;
		, UTF-8
		return ParseJson(whr.ResponseText)
}</code></pre></div><p>Буду очень благодарен за помощь!</p>]]></content>
			<author>
				<name><![CDATA[Finx]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34499</uri>
			</author>
			<updated>2019-01-14T12:46:13Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131191#p131191</id>
		</entry>
</feed>
