Func _RusToURL_Encode($URL)
$result=''
Local $aArray = StringSplit($URL,'')
For $i=1 To $aArray[0]
If Hex(Asc($aArray[$i]), 2) = 20 Then
$result&= "+";здесь вместо пробела в моем случае требовался именно плюс, без этого условия преобразует пробел в %20
Else
$result&= '%'&Hex(Asc($aArray[$i]), 2)
EndIf
Next
return $result
EndFunc
Func __WinHttpURLEncode($sData, $iEncoding = 1)
Local $aData = StringToASCIIArray($sData, Default, Default, $iEncoding)
Local $sOut
For $i = 0 To UBound($aData) - 1
Switch $aData[$i]
Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126
$sOut &= Chr($aData[$i])
Case 32
$sOut &= "+"
Case Else
$sOut &= "%" & Hex($aData[$i], 2)
EndSwitch
Next
Return $sOut
EndFunc ;==>__WinHttpURLEncode
seller_name%3D%26%231042%3B%26%231072%3B%26%231089%3B%26%231103%3B+%26%231055%3B%26%231091%3B%26%231087%3B%26%231082%3B%26%231080%3B%26%231085%3B%26email%3Demail%40mail.com%26desc%3D%26%231086%3B%26%231087%3B%26%231080%3B%26%231089%3B%26%231072%3B%26%231085%3B%26%231080%3B%26%231077%3B
Func __WinHttpURLEncode($sData, $iEncoding = 2)
$dataToSend='seller_name='&__WinHttpURLEncode('Вася Пупкин', $iEncoding = 2)&'&email='&__WinHttpURLEncode('[email protected]', $iEncoding = 2)&'&desc='&__WinHttpURLEncode('описание', $iEncoding = 2)
StringFromASCIIArray(StringToASCIIArray("ÐнÑÑÑÑкÑÐ¸Ñ Ð¿Ð¾ ÑÑÑановке.htm", 0, Default, 0), 0, Default, 2)
$sString = '=D0=A1=D0=BB=D0=B0=D0=B2=D0=B0=20=D0=9A=D0=B0=D0=BB=D0=B0=D1=87=D0=B5=D0=B2'
$ANSI = _Encoding_QuotedPrintableToANSI($sString)
$UTF8DecodedString = _Encoding_ANSIToUTF8($ANSI)
раскодировать строку
$sString = '=D0=A1=D0=BB=D0=B0=D0=B2=D0=B0=20=D0=9A=D0=B0=D0=BB=D0=B0=D1=87=D0=B5=D0=B2'
$sConvert = BinaryToString("0x" & StringReplace($sString, "=", ""), 4)
ConsoleWrite($sConvert & @CRLF)
#include "Encoding.au3"
$sString = '=D0=A1=D0=BB=D0=B0=D0=B2=D0=B0=20=D0=9A=D0=B0=D0=BB=D0=B0=D1=87=D0=B5=D0=B2'
$sString = _Encoding_QuotedPrintableToANSI($sString)
If _Encoding_IsUTF8Format($sString) Then
$sString = _Encoding_UTF8ToANSI($sString)
EndIf
MsgBox(64, 'Title', $sString)
$sString = '=D0=A1=D0=BB=D0=B0=D0=B2=D0=B0=20=D0=9A=D0=B0=D0=BB=D0=B0=D1=87=D0=B5=D0=B2'
$sString = _Encoding_RemoteEncode($sString, 'quoted_printable_decode')
MsgBox(64, 'Title', $sString)
Func _Encoding_RemoteEncode($sStr, $sEncoding, $bUnicode = True)
$sStr = BinaryToString(InetRead(StringFormat('http://autoit-script.ru/Tools/encode.php?str=%s&enc=%s', $sStr, $sEncoding)), $bUnicode ? 4 : 0)
Return $sStr
EndFunc
<?php
$sStr = $_GET['str'];
$sEncoding = $_GET['enc'];
echo $sEncoding($sStr);
?>
$sString = 'тест'
$sString = _Encoding_RemoteEncode($sString, 'utf8_encode', False)
MsgBox(64, 'Title', $sString)
$sString = _Encoding_RemoteEncode($sString, 'utf8_decode', False)
MsgBox(64, 'Title', $sString)
$sString = _Encoding_RemoteEncode($sString, 'base64_encode', False)
MsgBox(64, 'Title', $sString)
$sString = _Encoding_RemoteEncode($sString, 'base64_decode', False)
MsgBox(64, 'Title', $sString)
Func _Encoding_RemoteEncode($sStr, $sEncoding, $bUnicode = True)
$sStr = BinaryToString(InetRead(StringFormat('http://autoit-script.ru/Tools/encode.php?str=%s&enc=%s', $sStr, $sEncoding)), $bUnicode ? 4 : 0)
Return $sStr
EndFunc
CreatoR сказал(а):Код:#include "Encoding.au3" $sString = '=D0=A1=D0=BB=D0=B0=D0=B2=D0=B0=20=D0=9A=D0=B0=D0=BB=D0=B0=D1=87=D0=B5=D0=B2' $sString = _Encoding_QuotedPrintableToANSI($sString) If _Encoding_IsUTF8Format($sString) Then $sString = _Encoding_UTF8ToANSI($sString) EndIf MsgBox(64, 'Title', $sString)
Название функции неудачное, наверное должно быть _Encoding_QuotedPrintableDecode.
InnI сказал(а):Hemul_Y [?]
раскодировать строкуКод:$sString = '=D0=A1=D0=BB=D0=B0=D0=B2=D0=B0=20=D0=9A=D0=B0=D0=BB=D0=B0=D1=87=D0=B5=D0=B2' $sConvert = BinaryToString("0x" & StringReplace($sString, "=", ""), 4) ConsoleWrite($sConvert & @CRLF)
$x = Encoding_UTF8ToUnicode_API("Женя")
ConsoleWrite("длинна: " & StringLen($x) & ' ' & $x & @CRLF)
$UnicodeHex3 = StringMid($UnicodeHex2, 3, 2) & StringMid($UnicodeHex2, 1, 2)
If $UnicodeHex3 = "0000" Then ExitLoop
Func _Encoding_UTF8ToUnicode_API($sUTF8_String)
Local $iBufferSize = StringLen($sUTF8_String)
Local $stBuffer = DllStructCreate("byte[" & $iBufferSize & "]")
DllCall("Kernel32.dll", "int", "MultiByteToWideChar", _
"int", 65001, _
"int", 0, _
"str", $sUTF8_String, _
"int", StringLen($sUTF8_String), _
"ptr", DllStructGetPtr($stBuffer), _
"int", $iBufferSize)
Local $bUnicodeBinary = DllStructGetData($stBuffer, 1)
Local $nUnicodeHex = StringReplace($bUnicodeBinary, "0x", "")
Local $iStrLen = StringLen($nUnicodeHex)
Local $nHexTmp, $sRet
For $i = 1 To $iStrLen Step 4
$nHexTmp = StringMid($nUnicodeHex, $i, 4)
$sRet &= ChrW(Dec(StringMid($nHexTmp, 3, 2) & StringMid($nHexTmp, 1, 2)))
Next
Return $sRet
EndFunc
Func _Encoding_UTF8ToUnicode_API($sUTF8_String)
Local $iBufferSize = StringLen($sUTF8_String)
Local $stBuffer = DllStructCreate("byte[" & $iBufferSize * 2 & "]")
DllCall("Kernel32.dll", "int", "MultiByteToWideChar", _
"int", 65001, _
"int", 0, _
"str", $sUTF8_String, _
"int", StringLen($sUTF8_String), _
"ptr", DllStructGetPtr($stBuffer), _
"int", $iBufferSize)
Local $bUnicodeBinary = DllStructGetData($stBuffer, 1)
Local $nUnicodeHex = StringReplace($bUnicodeBinary, "0x", "")
Local $iStrLen = StringLen($nUnicodeHex)
Local $nHexTmp, $sRet
For $i = 1 To $iStrLen Step 4
$nHexTmp = StringMid($nUnicodeHex, $i, 4)
$iDecTmp = Dec(StringMid($nHexTmp, 3, 2) & StringMid($nHexTmp, 1, 2))
If $iDecTmp Then
$sRet &= ChrW($iDecTmp)
EndIf
Next
Return $sRet
EndFunc