Code: Select all
:global fUnicodeToURL
:if (!any $fUnicodeToURL) do={ :global fUnicodeToURL do={
:local Ubytes [:tonum $1]
:local EscapeStr ""
:local HighByte
:local LowByte
:local firstList {1088;1089;1090;1091;1092;1093;1094;1095;1096;1097;1098;1099;1100;1101;1102;1103}
:if ([:typeof [:find $firstList "$Ubytes"]] != "nil") do={
#for lower
:set HighByte (0xD1 | (($Ubytes - 0x0430 + 0xC0) >> 8))
:set LowByte (0x80 | ($Ubytes & 0x3F))
:put ("LowByte")
} else={
#for upper
:set HighByte (0xD0 | (($Ubytes - 0x0410 + 0xC0) >> 8))
:set LowByte (0x80 | ($Ubytes & 0xFF))
:put ("HighByte")
}
:set EscapeStr ( "%".[:tostr [:pick "0123456789ABCDEF" ( $HighByte >> 4 & 0xF)]].[:tostr [:pick "0123456789ABCDEF" ( $HighByte & 0xF)]])
:set EscapeStr ($EscapeStr . "%".[:tostr [:pick "0123456789ABCDEF" ( $LowByte >> 4 & 0xF)]].[:tostr [:pick "0123456789ABCDEF" ( $LowByte & 0xF)]])
:return $EscapeStr
}}