/ip address print where (network + 1) = 192.168.88.1
Code: Select all
# TAG # lastcheck (25 Mar 2014, 13:34)
{
:local source 10.31.42.56/16
:local ip [:toip [:pick $source 0 [:find $source "/"]]]
:local prefix [:tonum [:pick $source ([:find $source "/"] + 1) [:len $source]]]
:local submask (255.255.255.255<<(32 - $prefix))
:local addrspace (~$submask)
:local totip ([:tonum $addrspace] + 1)
:local network ($ip & $submask)
:local broadcast ($ip | $addrspace)
:local first (($network + 1) - ($prefix / 31))
:local last (($broadcast - 1) + ($prefix / 31))
:local usable (($last - $network) + ($prefix / 31))
:put " Source: $source"
:put " IP: $ip"
:put "Subnet Prefix: $prefix"
:put " Subnet Mask: $submask"
:put "Address Space: $addrspace"
:put " Total IPs: $totip"
:put " Network* IP: $network"
:put "Broadcast* IP: $broadcast"
:put " First* IP: $first"
:put " Last* IP: $last"
:put " Usable* IPs: $usable"
}
{
:local sourceip 10.31.42.56
:local sourcesub 255.255.0.0
:local ip [:toip $sourceip]
:local submask [:toip $sourcesub]
:local addrspace (~$submask)
:local tempsub [:tonum $addrspace]
:local prefix 32
:while ($tempsub > 0) do={:set tempsub ($tempsub / 2); :set prefix ($prefix - 1)}
:local totip ([:tonum $addrspace] + 1)
:local network ($ip & $submask)
:local broadcast ($ip | $addrspace)
:local first (($network + 1) - ($prefix / 31))
:local last (($broadcast - 1) + ($prefix / 31))
:local usable (($last - $network) + ($prefix / 31))
:put " Source IP: $ip"
:put " Source Mask: $submask"
:put "Subnet Prefix: $prefix"
:put "Address Space: $addrspace"
:put " Total IPs: $totip"
:put " Network* IP: $network"
:put "Broadcast* IP: $broadcast"
:put " First* IP: $first"
:put " Last* IP: $last"
:put " Usable* IPs: $usable"
}
:put [:tonum 127.0.0.1]
:put (0.0.0.0 + 2130706433)
:put [$num2hex [:tonum 127.0.0.1]]
:put (0.0.0.0 + 0x7F000001)
:global dec2bin do={
:local number [:tonum $1]
:local b8 0 ; :if ($number & 128) do={:set b8 1}
:local b7 0 ; :if ($number & 64) do={:set b7 1}
:local b6 0 ; :if ($number & 32) do={:set b6 1}
:local b5 0 ; :if ($number & 16) do={:set b5 1}
:local b4 0 ; :if ($number & 8) do={:set b4 1}
:local b3 0 ; :if ($number & 4) do={:set b3 1}
:local b2 0 ; :if ($number & 2) do={:set b2 1}
:local b1 0 ; :if ($number & 1) do={:set b1 1}
:return "$b8$b7$b6$b5$b4$b3$b2$b1"
}
:global hex2bin do={
:local conv $1
:if (!($conv~"(^0x|^)[0-9a-fA-F]{2}\$")) do={:return "00000000"}
:if ([:typeof [:find $conv "0x" -1]] = "nil") do={:set conv "0x$conv"}
:local number [:tonum $conv]
:local b8 0 ; :if ($number & 128) do={:set b8 1}
:local b7 0 ; :if ($number & 64) do={:set b7 1}
:local b6 0 ; :if ($number & 32) do={:set b6 1}
:local b5 0 ; :if ($number & 16) do={:set b5 1}
:local b4 0 ; :if ($number & 8) do={:set b4 1}
:local b3 0 ; :if ($number & 4) do={:set b3 1}
:local b2 0 ; :if ($number & 2) do={:set b2 1}
:local b1 0 ; :if ($number & 1) do={:set b1 1}
:return "$b8$b7$b6$b5$b4$b3$b2$b1"
}
:global bin2dec do={
:local bin $1
:local dec 0
:local mol 1
:if (!($bin~"^[0-1]{8}\$")) do={:return 0}
:for pos from=1 to=8 do={
:local temp [:tonum [:pick $bin (8 - $pos) (8 - $pos + 1)]]
:set dec ($dec + ($temp * $mol))
:set mol ($mol * 2)
}
:return $dec
}
:global bin2hex do={
:local bin $1
:local dec 0
:local mol 1
:if (!($bin~"^[0-1]{8}\$")) do={:return "0x00"}
:for pos from=1 to=8 do={
:local temp [:tonum [:pick $bin (8 - $pos) (8 - $pos + 1)]]
:set dec ($dec + ($temp * $mol))
:set mol ($mol * 2)
}
:local hexadec "0"
:local remainder 0
:local hexChars "0123456789ABCDEF"
:if ($dec > 0) do={:set hexadec ""}
:while ( $dec > 0 ) do={
:set remainder ($dec % 16)
:set dec (($dec-$remainder) / 16)
:set hexadec ([:pick $hexChars $remainder].$hexadec)
}
:if ([:len $hexadec] = 1) do={:set hexadec "0$hexadec"}
:return "0x$hexadec"
}
:global binQW2dec do={
:local bin $1
:local dec 0
:local mol 1
:local lgt [:len $bin]
:if (!($bin~"^[0-1]{$lgt}\$")) do={:return 0}
:for pos from=1 to=$lgt do={
:local temp [:tonum [:pick $bin ($lgt - $pos) ($lgt - $pos + 1)]]
:set dec ($dec + ($temp * $mol))
:set mol ($mol * 2)
}
:return $dec
}
:global binQW2hex do={
:local bin $1
:local dec 0
:local mol 1
:local lgt [:len $bin]
:if (!($bin~"^[0-1]{$lgt}\$")) do={:return "0x00"}
:for pos from=1 to=$lgt do={
:local temp [:tonum [:pick $bin ($lgt - $pos) ($lgt - $pos + 1)]]
:set dec ($dec + ($temp * $mol))
:set mol ($mol * 2)
}
:local firstchar ""
:if ($dec < 0) do={
:local chk (($dec & 0x7000000000000000) >> 60)
:set firstchar [:pick "89ABCDEF" $chk ($chk + 1)]
:set dec ($dec & 0x0FFFFFFFFFFFFFFF)
}
:local hexadec "0"
:local remainder 0
:local hexChars "0123456789ABCDEF"
:if ($dec > 0) do={:set hexadec ""}
:while ( $dec > 0 ) do={
:set remainder ($dec % 16)
:set dec (($dec-$remainder) / 16)
:set hexadec ([:pick $hexChars $remainder].$hexadec)
}
:if ($firstchar != "") do={
:set hexadec "00000000000000$hexadec"
:set hexadec "$firstchar$[:pick $hexadec ([:len $hexadec] - 15) [:len $hexadec]]"
}
:return "0x$hexadec"
}
:put 0xFF85
:put [:tonum "0xFF85"]
:global hex2dec do={
:local conv $1
:if (!($conv~"^[0-9a-fA-F]+\$")) do={:return 0}
:if ([:typeof [:find $conv "0x" -1]] = "nil") do={:set conv "0x$conv"}
:return [:tonum $conv]
}
:global ASCIItoCP1252toUNICODE do={
:local ascii "\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\
\10\11\12\13\14\15\16\17\18\19\1A\1B\1C\1D\1E\1F\
\20\21\22\23\24\25\26\27\28\29\2A\2B\2C\2D\2E\2F\
\30\31\32\33\34\35\36\37\38\39\3A\3B\3C\3D\3E\3F\
\40\41\42\43\44\45\46\47\48\49\4A\4B\4C\4D\4E\4F\
\50\51\52\53\54\55\56\57\58\59\5A\5B\5C\5D\5E\5F\
\60\61\62\63\64\65\66\67\68\69\6A\6B\6C\6D\6E\6F\
\70\71\72\73\74\75\76\77\78\79\7A\7B\7C\7D\7E\7F\
\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F\
\90\91\92\93\94\95\96\97\98\99\9A\9B\9C\9D\9E\9F\
\A0\A1\A2\A3\A4\A5\A6\A7\A8\A9\AA\AB\AC\AD\AE\AF\
\B0\B1\B2\B3\B4\B5\B6\B7\B8\B9\BA\BB\BC\BD\BE\BF\
\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF\
\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\
\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB\EC\ED\EE\EF\
\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF"
:local CP1252toUNICODE {"0000";"0001";"0002";"0003";"0004";"0005";"0006";"0007";"0008";"0009";"000A";"000B";"000C";"000D";"000E";"000F";
"0010";"0011";"0012";"0013";"0014";"0015";"0016";"0017";"0018";"0019";"001A";"001B";"001C";"001D";"001E";"001F";
"0020";"0021";"0022";"0023";"0024";"0025";"0026";"0027";"0028";"0029";"002A";"002B";"002C";"002D";"002E";"002F";
"0030";"0031";"0032";"0033";"0034";"0035";"0036";"0037";"0038";"0039";"003A";"003B";"003C";"003D";"003E";"003F";
"0040";"0041";"0042";"0043";"0044";"0045";"0046";"0047";"0048";"0049";"004A";"004B";"004C";"004D";"004E";"004F";
"0050";"0051";"0052";"0053";"0054";"0055";"0056";"0057";"0058";"0059";"005A";"005B";"005C";"005D";"005E";"005F";
"0060";"0061";"0062";"0063";"0064";"0065";"0066";"0067";"0068";"0069";"006A";"006B";"006C";"006D";"006E";"006F";
"0070";"0071";"0072";"0073";"0074";"0075";"0076";"0077";"0078";"0079";"007A";"007B";"007C";"007D";"007E";"007F";
"20AC";"FFFD";"201A";"0192";"201E";"2026";"2020";"2021";"02C6";"2030";"0160";"2039";"0152";"FFFD";"017D";"FFFD";
"FFFD";"2018";"2019";"201C";"201D";"2022";"2013";"2014";"02DC";"2122";"0161";"203A";"0153";"FFFD";"017E";"0178";
"00A0";"00A1";"00A2";"00A3";"00A4";"00A5";"00A6";"00A7";"00A8";"00A9";"00AA";"00AB";"00AC";"00AD";"00AE";"00AF";
"00B0";"00B1";"00B2";"00B3";"00B4";"00B5";"00B6";"00B7";"00B8";"00B9";"00BA";"00BB";"00BC";"00BD";"00BE";"00BF";
"00C0";"00C1";"00C2";"00C3";"00C4";"00C5";"00C6";"00C7";"00C8";"00C9";"00CA";"00CB";"00CC";"00CD";"00CE";"00CF";
"00D0";"00D1";"00D2";"00D3";"00D4";"00D5";"00D6";"00D7";"00D8";"00D9";"00DA";"00DB";"00DC";"00DD";"00DE";"00DF";
"00E0";"00E1";"00E2";"00E3";"00E4";"00E5";"00E6";"00E7";"00E8";"00E9";"00EA";"00EB";"00EC";"00ED";"00EE";"00EF";
"00F0";"00F1";"00F2";"00F3";"00F4";"00F5";"00F6";"00F7";"00F8";"00F9";"00FA";"00FB";"00FC";"00FD";"00FE";"00FF"
}
:local string $1
:if (([:typeof $string] != "str") or ($string = "")) do={ :return "" }
:local lenstr [:len $string]
:local constr ""
:for pos from=0 to=($lenstr - 1) do={
:local unicode "0x$($CP1252toUNICODE->[:find $ascii [:pick $string $pos ($pos + 1)] -1])"
:set constr "$constr$unicode"
}
:return $constr
}
:put [$ASCIItoCP1252toUNICODE "test"]
:global ASCIItoCP1252toUTF8 do={
:local ascii "\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\
\10\11\12\13\14\15\16\17\18\19\1A\1B\1C\1D\1E\1F\
\20\21\22\23\24\25\26\27\28\29\2A\2B\2C\2D\2E\2F\
\30\31\32\33\34\35\36\37\38\39\3A\3B\3C\3D\3E\3F\
\40\41\42\43\44\45\46\47\48\49\4A\4B\4C\4D\4E\4F\
\50\51\52\53\54\55\56\57\58\59\5A\5B\5C\5D\5E\5F\
\60\61\62\63\64\65\66\67\68\69\6A\6B\6C\6D\6E\6F\
\70\71\72\73\74\75\76\77\78\79\7A\7B\7C\7D\7E\7F\
\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F\
\90\91\92\93\94\95\96\97\98\99\9A\9B\9C\9D\9E\9F\
\A0\A1\A2\A3\A4\A5\A6\A7\A8\A9\AA\AB\AC\AD\AE\AF\
\B0\B1\B2\B3\B4\B5\B6\B7\B8\B9\BA\BB\BC\BD\BE\BF\
\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF\
\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\
\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB\EC\ED\EE\EF\
\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF"
:local CP1252toUTF8 {"00";"01";"02";"03";"04";"05";"06";"07";"08";"09";"0A";"0B";"0C";"0D";"0E";"0F";
"10";"11";"12";"13";"14";"15";"16";"17";"18";"19";"1A";"1B";"1C";"1D";"1E";"1F";
"20";"21";"22";"23";"24";"25";"26";"27";"28";"29";"2A";"2B";"2C";"2D";"2E";"2F";
"30";"31";"32";"33";"34";"35";"36";"37";"38";"39";"3A";"3B";"3C";"3D";"3E";"3F";
"40";"41";"42";"43";"44";"45";"46";"47";"48";"49";"4A";"4B";"4C";"4D";"4E";"4F";
"50";"51";"52";"53";"54";"55";"56";"57";"58";"59";"5A";"5B";"5C";"5D";"5E";"5F";
"60";"61";"62";"63";"64";"65";"66";"67";"68";"69";"6A";"6B";"6C";"6D";"6E";"6F";
"70";"71";"72";"73";"74";"75";"76";"77";"78";"79";"7A";"7B";"7C";"7D";"7E";"7F";
"E282AC";"EFBFBD";"E2809A";"C692";"E2809E";"E280A6";"E280A0";"E280A1";"CB86";"E280B0";"C5A0";"E280B9";"C592";"EFBFBD";"C5BD";"EFBFBD";
"EFBFBD";"E28098";"E28099";"E2809C";"E2809D";"E280A2";"E28093";"E28094";"CB9C";"E284A2";"C5A1";"E280BA";"C593";"EFBFBD";"C5BE";"C5B8";
"C2A0";"C2A1";"C2A2";"C2A3";"C2A4";"C2A5";"C2A6";"C2A7";"C2A8";"C2A9";"C2AA";"C2AB";"C2AC";"C2AD";"C2AE";"C2AF";
"C2B0";"C2B1";"C2B2";"C2B3";"C2B4";"C2B5";"C2B6";"C2B7";"C2B8";"C2B9";"C2BA";"C2BB";"C2BC";"C2BD";"C2BE";"C2BF";
"C380";"C381";"C382";"C383";"C384";"C385";"C386";"C387";"C388";"C389";"C38A";"C38B";"C38C";"C38D";"C38E";"C38F";
"C390";"C391";"C392";"C393";"C394";"C395";"C396";"C397";"C398";"C399";"C39A";"C39B";"C39C";"C39D";"C39E";"C39F";
"C3A0";"C3A1";"C3A2";"C3A3";"C3A4";"C3A5";"C3A6";"C3A7";"C3A8";"C3A9";"C3AA";"C3AB";"C3AC";"C3AD";"C3AE";"C3AF";
"C3B0";"C3B1";"C3B2";"C3B3";"C3B4";"C3B5";"C3B6";"C3B7";"C3B8";"C3B9";"C3BA";"C3BB";"C3BC";"C3BD";"C3BE";"C3BF"
}
:local string $1
:if (([:typeof $string] != "str") or ($string = "")) do={ :return "" }
:local lenstr [:len $string]
:local constr ""
:for pos from=0 to=($lenstr - 1) do={
:local utf ($CP1252toUTF8->[:find $ascii [:pick $string $pos ($pos + 1)] -1])
:local sym ""
:if ([:len $utf] = 2) do={:set sym "%$[:pick $utf 0 2]" }
:if ([:len $utf] = 4) do={:set sym "%$[:pick $utf 0 2]%$[:pick $utf 2 4]" }
:if ([:len $utf] = 6) do={:set sym "%$[:pick $utf 0 2]%$[:pick $utf 2 4]%$[:pick $utf 4 6]" }
:set constr "$constr$sym"
}
:return $constr
}
:put [$ASCIItoCP1252toUTF8 "test"]
:global dec2bin do={
:local number [:tonum $1]
:local ret ""
:local rshift 7
:if ($number > 0xFF) do={:set rshift 15}
:if ($number > 0xFFFF) do={:set rshift 31}
:if ($number > 0xFFFFFFFF) do={:set rshift 63}
:for i from=0 to=$rshift step=1 do={
:set ret "$(($number >> $i) & 1)$ret"
}
:return $ret
}
:global hex2bin do={
:local conv $1
:if (!($conv~"(^0x|^)[0-9a-fA-F]+\$")) do={:return "00000000"}
:if ([:typeof [:find $conv "0x" -1]] = "nil") do={:set conv "0x$conv"}
:local number [:tonum $conv]
:local ret ""
:local rshift 7
:if ($number > 0xFF) do={:set rshift 15}
:if ($number > 0xFFFF) do={:set rshift 31}
:if ($number > 0xFFFFFFFF) do={:set rshift 63}
:for i from=0 to=$rshift step=1 do={
:set ret "$(($number >> $i) & 1)$ret"
}
:return $ret
}
:global ASCIItoCP1252toURLencode do={
:local ascii "\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\
\10\11\12\13\14\15\16\17\18\19\1A\1B\1C\1D\1E\1F\
\20\21\22\23\24\25\26\27\28\29\2A\2B\2C\2D\2E\2F\
\30\31\32\33\34\35\36\37\38\39\3A\3B\3C\3D\3E\3F\
\40\41\42\43\44\45\46\47\48\49\4A\4B\4C\4D\4E\4F\
\50\51\52\53\54\55\56\57\58\59\5A\5B\5C\5D\5E\5F\
\60\61\62\63\64\65\66\67\68\69\6A\6B\6C\6D\6E\6F\
\70\71\72\73\74\75\76\77\78\79\7A\7B\7C\7D\7E\7F\
\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F\
\90\91\92\93\94\95\96\97\98\99\9A\9B\9C\9D\9E\9F\
\A0\A1\A2\A3\A4\A5\A6\A7\A8\A9\AA\AB\AC\AD\AE\AF\
\B0\B1\B2\B3\B4\B5\B6\B7\B8\B9\BA\BB\BC\BD\BE\BF\
\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF\
\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\
\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB\EC\ED\EE\EF\
\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF"
:local CP1252toURLe {"00";"01";"02";"03";"04";"05";"06";"07";"08";"09";"0A";"0B";"0C";"0D";"0E";"0F";
"10";"11";"12";"13";"14";"15";"16";"17";"18";"19";"1A";"1B";"1C";"1D";"1E";"1F";
"+";"21";"22";"23";"24";"25";"26";"27";"28";"29";"2A";"2B";"2C";"-";".";"2F";
"0";"1";"2";"3";"4";"5";"6";"7";"8";"9";"3A";"3B";"3C";"3D";"3E";"3F";
"40";"A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"K";"L";"M";"N";"O";
"P";"Q";"R";"S";"T";"U";"V";"W";"X";"Y";"Z";"5B";"5C";"5D";"5E";"_";
"60";"a";"b";"c";"d";"e";"f";"g";"h";"i";"j";"k";"l";"m";"n";"o";
"p";"q";"r";"s";"t";"u";"v";"w";"x";"y";"z";"7B";"7C";"7D";"~";"7F";
"E282AC";"EFBFBD";"E2809A";"C692";"E2809E";"E280A6";"E280A0";"E280A1";"CB86";"E280B0";"C5A0";"E280B9";"C592";"EFBFBD";"C5BD";"EFBFBD";
"EFBFBD";"E28098";"E28099";"E2809C";"E2809D";"E280A2";"E28093";"E28094";"CB9C";"E284A2";"C5A1";"E280BA";"C593";"EFBFBD";"C5BE";"C5B8";
"C2A0";"C2A1";"C2A2";"C2A3";"C2A4";"C2A5";"C2A6";"C2A7";"C2A8";"C2A9";"C2AA";"C2AB";"C2AC";"C2AD";"C2AE";"C2AF";
"C2B0";"C2B1";"C2B2";"C2B3";"C2B4";"C2B5";"C2B6";"C2B7";"C2B8";"C2B9";"C2BA";"C2BB";"C2BC";"C2BD";"C2BE";"C2BF";
"C380";"C381";"C382";"C383";"C384";"C385";"C386";"C387";"C388";"C389";"C38A";"C38B";"C38C";"C38D";"C38E";"C38F";
"C390";"C391";"C392";"C393";"C394";"C395";"C396";"C397";"C398";"C399";"C39A";"C39B";"C39C";"C39D";"C39E";"C39F";
"C3A0";"C3A1";"C3A2";"C3A3";"C3A4";"C3A5";"C3A6";"C3A7";"C3A8";"C3A9";"C3AA";"C3AB";"C3AC";"C3AD";"C3AE";"C3AF";
"C3B0";"C3B1";"C3B2";"C3B3";"C3B4";"C3B5";"C3B6";"C3B7";"C3B8";"C3B9";"C3BA";"C3BB";"C3BC";"C3BD";"C3BE";"C3BF"
}
:local string $1
:if (([:typeof $string] != "str") or ($string = "")) do={ :return "" }
:local lenstr [:len $string]
:local constr ""
:for pos from=0 to=($lenstr - 1) do={
:local urle ($CP1252toURLe->[:find $ascii [:pick $string $pos ($pos + 1)] -1])
:local sym $urle
:if ([:len $urle] = 2) do={:set sym "%$[:pick $urle 0 2]" }
:if ([:len $urle] = 4) do={:set sym "%$[:pick $urle 0 2]%$[:pick $urle 2 4]" }
:if ([:len $urle] = 6) do={:set sym "%$[:pick $urle 0 2]%$[:pick $urle 2 4]%$[:pick $urle 4 6]" }
:set constr "$constr$sym"
}
:return $constr
}
:put [$ASCIItoCP1252toURLencode ("The Euro symbol is \80 (on CP1252)")]
:global UTF8toURLencode do={
:local ascii "\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\
\10\11\12\13\14\15\16\17\18\19\1A\1B\1C\1D\1E\1F\
\20\21\22\23\24\25\26\27\28\29\2A\2B\2C\2D\2E\2F\
\30\31\32\33\34\35\36\37\38\39\3A\3B\3C\3D\3E\3F\
\40\41\42\43\44\45\46\47\48\49\4A\4B\4C\4D\4E\4F\
\50\51\52\53\54\55\56\57\58\59\5A\5B\5C\5D\5E\5F\
\60\61\62\63\64\65\66\67\68\69\6A\6B\6C\6D\6E\6F\
\70\71\72\73\74\75\76\77\78\79\7A\7B\7C\7D\7E\7F\
\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F\
\90\91\92\93\94\95\96\97\98\99\9A\9B\9C\9D\9E\9F\
\A0\A1\A2\A3\A4\A5\A6\A7\A8\A9\AA\AB\AC\AD\AE\AF\
\B0\B1\B2\B3\B4\B5\B6\B7\B8\B9\BA\BB\BC\BD\BE\BF\
\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF\
\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\
\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB\EC\ED\EE\EF\
\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF"
:local UTF8toURLe {"00";"01";"02";"03";"04";"05";"06";"07";"08";"09";"0A";"0B";"0C";"0D";"0E";"0F";
"10";"11";"12";"13";"14";"15";"16";"17";"18";"19";"1A";"1B";"1C";"1D";"1E";"1F";
"+";"21";"22";"23";"24";"25";"26";"27";"28";"29";"2A";"2B";"2C";"-";".";"2F";
"0";"1";"2";"3";"4";"5";"6";"7";"8";"9";"3A";"3B";"3C";"3D";"3E";"3F";
"40";"A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"K";"L";"M";"N";"O";
"P";"Q";"R";"S";"T";"U";"V";"W";"X";"Y";"Z";"5B";"5C";"5D";"5E";"_";
"60";"a";"b";"c";"d";"e";"f";"g";"h";"i";"j";"k";"l";"m";"n";"o";
"p";"q";"r";"s";"t";"u";"v";"w";"x";"y";"z";"7B";"7C";"7D";"~";"7F";
"80";"81";"82";"83";"84";"85";"86";"87";"88";"89";"8A";"8B";"8C";"8D";"8E";"8F";
"90";"91";"92";"93";"94";"95";"96";"97";"98";"99";"9A";"9B";"9C";"9D";"9E";"9F";
"A0";"A1";"A2";"A3";"A4";"A5";"A6";"A7";"A8";"A9";"AA";"AB";"AC";"AD";"AE";"AF";
"B0";"B1";"B2";"B3";"B4";"B5";"B6";"B7";"B8";"B9";"BA";"BB";"BC";"BD";"BE";"BF";
"C0";"C1";"C2";"C3";"C4";"C5";"C6";"C7";"C8";"C9";"CA";"CB";"CC";"CD";"CE";"CF";
"D0";"D1";"D2";"D3";"D4";"D5";"D6";"D7";"D8";"D9";"DA";"DB";"DC";"DD";"DE";"DF";
"E0";"E1";"E2";"E3";"E4";"E5";"E6";"E7";"E8";"E9";"EA";"EB";"EC";"ED";"EE";"EF";
"F0";"F1";"F2";"F3";"F4";"F5";"F6";"F7";"F8";"F9";"FA";"FB";"FC";"FD";"FE";"FF"
}
:local string $1
:if (([:typeof $string] != "str") or ($string = "")) do={ :return "" }
:local lenstr [:len $string]
:local constr ""
:for pos from=0 to=($lenstr - 1) do={
:local urle ($UTF8toURLe->[:find $ascii [:pick $string $pos ($pos + 1)] -1])
:local sym $urle
:if ([:len $urle] = 2) do={:set sym "%$[:pick $urle 0 2]" }
:set constr "$constr$sym"
}
:return $constr
}
:put [$UTF8toURLencode ("The Euro symbol is \E2\82\AC (on UTF-8)")]
:global CP1252toHexGSM7 do={
:local ascii "\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\
\10\11\12\13\14\15\16\17\18\19\1A\1B\1C\1D\1E\1F\
\20\21\22\23\24\25\26\27\28\29\2A\2B\2C\2D\2E\2F\
\30\31\32\33\34\35\36\37\38\39\3A\3B\3C\3D\3E\3F\
\40\41\42\43\44\45\46\47\48\49\4A\4B\4C\4D\4E\4F\
\50\51\52\53\54\55\56\57\58\59\5A\5B\5C\5D\5E\5F\
\60\61\62\63\64\65\66\67\68\69\6A\6B\6C\6D\6E\6F\
\70\71\72\73\74\75\76\77\78\79\7A\7B\7C\7D\7E\7F\
\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F\
\90\91\92\93\94\95\96\97\98\99\9A\9B\9C\9D\9E\9F\
\A0\A1\A2\A3\A4\A5\A6\A7\A8\A9\AA\AB\AC\AD\AE\AF\
\B0\B1\B2\B3\B4\B5\B6\B7\B8\B9\BA\BB\BC\BD\BE\BF\
\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF\
\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\
\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB\EC\ED\EE\EF\
\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF"
:local gsm7b {"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"0A";"20";"1B0D";"0D";"20";"20";
"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";
"20";"21";"22";"23";"02";"25";"26";"27";"28";"29";"2A";"2B";"2C";"2D";"2E";"2F";
"30";"31";"32";"33";"34";"35";"36";"37";"38";"39";"3A";"3B";"3C";"3D";"3E";"3F";
"00";"41";"42";"43";"44";"45";"46";"47";"48";"49";"4A";"4B";"4C";"4D";"4E";"4F";
"50";"51";"52";"53";"54";"55";"56";"57";"58";"59";"5A";"1B3C";"1B2F";"1B3E";"1B14";"11";
"27";"61";"62";"63";"64";"65";"66";"67";"68";"69";"6A";"6B";"6C";"6D";"6E";"6F";
"70";"71";"72";"73";"74";"75";"76";"77";"78";"79";"7A";"1B28";"1B40";"1B29";"1B3D";"20";
"1B65";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";
"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";
"20";"40";"20";"01";"24";"03";"20";"5F";"20";"20";"20";"20";"20";"20";"20";"20";
"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"20";"60";
"20";"20";"20";"20";"5B";"0E";"1C";"09";"20";"1F";"20";"20";"20";"20";"20";"20";
"20";"5D";"20";"20";"20";"20";"5C";"20";"0B";"20";"20";"20";"5E";"20";"20";"1E";
"7F";"20";"20";"20";"7B";"0F";"1D";"20";"04";"05";"20";"20";"07";"20";"20";"20";
"20";"7D";"08";"20";"20";"20";"7C";"20";"0C";"06";"20";"20";"7E";"20";"20";"20";
}
# CP1253 Greek do not support any 0x7F-0xFF except:
# Euro 0x80=1B65
# Pound 0xA3=01, Currency 0xA4=24, Yen 0xA5=03, Section 0xA7=5F
# Gamma 0xC3=13, Delta 0xC4=10, Theta 0xC8=19, Lambda 0xCB=14, Xi 0xCE=1A
# Pi 0xD0=16, Sigma 0xD3=18, Phi 0xD6=12, Psi 0xD8=17, Omega 0xD9=15
:local input $1
:if (([:typeof $input] != "str") or ($input = "")) do={:return ""}
:local inputlen [:len $input]
:local convstr ""
:for pos from=0 to=($inputlen - 1) do={
:local gsmchr "$($gsm7b->[:find $ascii [:pick $input $pos ($pos + 1)] -1])"
:set convstr "$convstr$gsmchr"
}
:return $convstr
}
[] > :put [$CP1252toHexGSM7 ("Hi to All! [@~)]")] 486920746F20416C6C21201B3C001B3D291B3E # calculate characters needed, max single GSM7 SMS is 160 characters [] > :put ([:len [$CP1252toHexGSM7 ("Hi to All! [@~)]")]] / 2) 19
:global HexGSM7toCP1252 do={
:local cp1252 {"\40";"\A3";"\24";"\A5";"\E8";"\E9";"\F9";"\EC";"\F2";"\C7";"\0A";"\D8";"\F8";"\0D";"\C5";"\E5";
"\20";"\5F";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\1B";"\C6";"\E6";"\DF";"\C9";
"\20";"\21";"\22";"\23";"\A4";"\25";"\26";"\27";"\28";"\29";"\2A";"\2B";"\2C";"\2D";"\2E";"\2F";
"\30";"\31";"\32";"\33";"\34";"\35";"\36";"\37";"\38";"\39";"\3A";"\3B";"\3C";"\3D";"\3E";"\3F";
"\A1";"\41";"\42";"\43";"\44";"\45";"\46";"\47";"\48";"\49";"\4A";"\4B";"\4C";"\4D";"\4E";"\4F";
"\50";"\51";"\52";"\53";"\54";"\55";"\56";"\57";"\58";"\59";"\5A";"\C4";"\D6";"\D1";"\DC";"\A7";
"\BF";"\61";"\62";"\63";"\64";"\65";"\66";"\67";"\68";"\69";"\6A";"\6B";"\6C";"\6D";"\6E";"\6F";
"\70";"\71";"\72";"\73";"\74";"\75";"\76";"\77";"\78";"\79";"\7A";"\E4";"\F6";"\F1";"\FC";"\E0";
"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\0C";"\20";"\20";"\0D";"\20";"\20";
"\20";"\20";"\20";"\20";"\5E";"\20";"\20";"\20";"\20";"\20";"\20";"\1B";"\20";"\20";"\20";"\20";
"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\7B";"\7D";"\20";"\20";"\20";"\20";"\20";"\5C";
"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\5B";"\7E";"\5D";"\20";
"\7C";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";
"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";
"\20";"\20";"\20";"\20";"\20";"\80";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";
"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20";"\20"
}
:local input [:tostr "$1"]
:local options [:tostr "$2"]
:local lowerarray {"a"="A";"b"="B";"c"="C";"d"="D";"e"="E";"f"="F"}
:if (!($input~"^[0-9A-Fa-f]*\$")) do={
:error "invalid characters: only 0-9, A-F and a-f are valid HexGSM7 values"
}
:if (!($options~"ignoreodd")) do={
:if (([:len $input] % 2) != 0) do={:error "Invalid length, is odd."}
}
:local position 0
:local output "" ; :local work "" ; :local worknum 0 ; :local chk1 "" ; :local chk2 ""
:while ($position < [:len $input]) do={
:set chk1 [:pick $input $position ($position + 1)]
:set chk2 [:pick $input ($position + 1) ($position + 2)]
:if ($chk1~"[a-f]") do={:set chk1 ($lowerarray->$chk1)}
:if ($chk2~"[a-f]") do={:set chk2 ($lowerarray->$chk2)}
:set work "$chk1$chk2"
:if ([:len $work] = 2) do={
:set worknum [:tonum "0x$work"]
:if ($worknum > 0x7F) do={:error "Invalid 7-bit value ($worknum)"}
:if ($work = "1B") do={
:set chk1 [:pick $input ($position + 2) ($position + 3)]
:set chk2 [:pick $input ($position + 3) ($position + 4)]
:if ($chk1~"[a-f]") do={:set chk1 ($lowerarray->$chk1)}
:if ($chk2~"[a-f]") do={:set chk2 ($lowerarray->$chk2)}
:set work "$chk1$chk2"
:if ([:len $work] = 2) do={
:set worknum [:tonum "0x$work"]
:if ($worknum > 0x7F) do={:error "Invalid 7-bit value after Escape (1B$worknum)"}
:if ($work = "1B") do={:error "Invalid Double Escape value"}
:set work ($cp1252->($worknum | 0x80))
} else={:set work ""}
:set position ($position + 2)
} else={
:set work ($cp1252->$worknum)
}
} else={:set work ""}
:set output "$output$work"
:set position ($position + 2)
}
:return $output
}
[] > :put [$HexGSM7toCP1252 ("486920746F20416C6C21201B3C001B3D291B3E")] Hi to All! [@~)]
:global gsm7topdu do={
:local input [:tostr "$1"]
:local options "$2"
:local numbyte2hex do={
:local input [:tonum $1]
:local hexchars "0123456789ABCDEF"
:local convert [:pick $hexchars (($input >> 4) & 0xF)]
:set convert ($convert.[:pick $hexchars ($input & 0xF)])
:return $convert
}
:local charsString ""
:for x from=0 to=15 step=1 do={ :for y from=0 to=15 step=1 do={
:local tmpHex "$[:pick "0123456789ABCDEF" $x ($x+1)]$[:pick "0123456789ABCDEF" $y ($y+1)]"
:set $charsString "$charsString$[[:parse "(\"\\$tmpHex\")"]]"
} }
:local chr2int do={:if (($1="") or ([:len $1] > 1) or ([:typeof $1] = "nothing")) do={:return -1}; :return [:find $2 $1 -1]}
:local position 0
:local output "" ; :local work ""
:local v1 0 ; :local v2 0 ; :local v3 0 ; :local v4 0 ; :local v5 0 ; :local v6 0 ; :local v7 0 ; :local v8 0
:local ch1 "" ; :local ch2 "" ; :local ch3 "" ; :local ch4 "" ; :local ch5 "" ; :local ch6 "" ; :local ch7 ""
:while ($position < [:len $input]) do={
:set work [:pick $input $position ($position + 8)]
:set v1 [$chr2int [:pick $work 0 1] $charsString]
:set v2 [$chr2int [:pick $work 1 2] $charsString]
:set v3 [$chr2int [:pick $work 2 3] $charsString]
:set v4 [$chr2int [:pick $work 3 4] $charsString]
:set v5 [$chr2int [:pick $work 4 5] $charsString]
:set v6 [$chr2int [:pick $work 5 6] $charsString]
:set v7 [$chr2int [:pick $work 6 7] $charsString]
:set v8 [$chr2int [:pick $work 7 8] $charsString]
:if (($v1 > 0x7F) or ($v2 > 0x7F) or ($v3 > 0x7F) or ($v4 > 0x7F) or \
($v5 > 0x7F) or ($v6 > 0x7F) or ($v7 > 0x7F) or ($v8 > 0x7F)) do={
:error "Unexpected 8-bit character value"
}
:set ch1 [$numbyte2hex ((($v2 & 0x01) << 7) + $v1 ) ]
:set ch2 [$numbyte2hex ((($v3 & 0x03) << 6) + ($v2 >> 1)) ]
:set ch3 [$numbyte2hex ((($v4 & 0x07) << 5) + ($v3 >> 2)) ]
:set ch4 [$numbyte2hex ((($v5 & 0x0F) << 4) + ($v4 >> 3)) ]
:set ch5 [$numbyte2hex ((($v6 & 0x1F) << 3) + ($v5 >> 4)) ]
:set ch6 [$numbyte2hex ((($v7 & 0x3F) << 2) + ($v6 >> 5)) ]
:set ch7 [$numbyte2hex ((($v8 & 0x7F) << 1) + ($v7 >> 6)) ]
:if ([:len $work] = 8) do={:set work "$ch1$ch2$ch3$ch4$ch5$ch6$ch7"
} else={ :if ([:len $work] = 7) do={:set work "$ch1$ch2$ch3$ch4$ch5$ch6$[$numbyte2hex ($v7 >> 6)]"
} else={ :if ([:len $work] = 6) do={:set work "$ch1$ch2$ch3$ch4$ch5$ch6"
} else={ :if ([:len $work] = 5) do={:set work "$ch1$ch2$ch3$ch4$ch5"
} else={ :if ([:len $work] = 4) do={:set work "$ch1$ch2$ch3$ch4"
} else={ :if ([:len $work] = 3) do={:set work "$ch1$ch2$ch3"
} else={ :if ([:len $work] = 2) do={:set work "$ch1$ch2"
} else={ :if ([:len $work] = 1) do={:set work "$ch1"
}}}}}}}}
:set output "$output$work"
:set position ($position + 8)
}
:if ($options~"addlen") do={:set output "$[$numbyte2hex [:len $input]]$output"}
:return $output
}
[] > :put [$gsm7topdu ("Hi to All!!!")] C83488FE0605D9EC502804 [] > :put [$gsm7topdu ("Hi to All!!!") "addlen"] 0CC83488FE0605D9EC502804
:global pdutogsm7 do={
:local input [:tostr "$1"]
:local options "$2$3"
:if ($options~"skiplen") do={:set input [:pick $input 1 [:len $input]]}
:local numbyte2hex do={
:local input [:tonum $1]
:local hexchars "0123456789ABCDEF"
:local convert [:pick $hexchars (($input >> 4) & 0xF)]
:set convert ($convert.[:pick $hexchars ($input & 0xF)])
:return $convert
}
:local charsString ""
:for x from=0 to=15 step=1 do={ :for y from=0 to=15 step=1 do={
:local tmpHex "$[:pick "0123456789ABCDEF" $x ($x+1)]$[:pick "0123456789ABCDEF" $y ($y+1)]"
:set $charsString "$charsString$[[:parse "(\"\\$tmpHex\")"]]"
} }
:local chr2int do={:if (($1="") or ([:len $1] > 1) or ([:typeof $1] = "nothing")) do={:return -1}; :return [:find $2 $1 -1]}
:local position 0
:local output "" ; :local work ""
:local v1 0 ; :local v2 0 ; :local v3 0 ; :local v4 0 ; :local v5 0 ; :local v6 0 ; :local v7 0
:local ch1 "" ; :local ch2 "" ; :local ch3 "" ; :local ch4 "" ; :local ch5 "" ; :local ch6 "" ; :local ch7 "" ; :local ch8 ""
:local errorinvalid "Invalid PDU data, expected value not provided."
:while ($position < [:len $input]) do={
:set work [:pick $input $position ($position + 7)]
:set v1 [$chr2int [:pick $work 0 1] $charsString]
:set v2 [$chr2int [:pick $work 1 2] $charsString]
:set v3 [$chr2int [:pick $work 2 3] $charsString]
:set v4 [$chr2int [:pick $work 3 4] $charsString]
:set v5 [$chr2int [:pick $work 4 5] $charsString]
:set v6 [$chr2int [:pick $work 5 6] $charsString]
:set v7 [$chr2int [:pick $work 6 7] $charsString]
:if (!($options~"ignoreinvalid")) do={
:if (([:len $work] = 1) and (($v1 >> 7) != 0)) do={:error $errorinvalid}
:if (([:len $work] = 2) and (($v2 >> 6) != 0)) do={:error $errorinvalid}
:if (([:len $work] = 3) and (($v3 >> 5) != 0)) do={:error $errorinvalid}
:if (([:len $work] = 4) and (($v4 >> 4) != 0)) do={:error $errorinvalid}
:if (([:len $work] = 5) and (($v5 >> 3) != 0)) do={:error $errorinvalid}
:if (([:len $work] = 6) and (($v6 >> 2) != 0)) do={:error $errorinvalid}
}
:set ch1 [$numbyte2hex ( $v1 & 0x7F) ]
:set ch2 [$numbyte2hex ((($v2 << 1) + ($v1 >> 7)) & 0x7F) ]
:set ch3 [$numbyte2hex ((($v3 << 2) + ($v2 >> 6)) & 0x7F) ]
:set ch4 [$numbyte2hex ((($v4 << 3) + ($v3 >> 5)) & 0x7F) ]
:set ch5 [$numbyte2hex ((($v5 << 4) + ($v4 >> 4)) & 0x7F) ]
:set ch6 [$numbyte2hex ((($v6 << 5) + ($v5 >> 3)) & 0x7F) ]
:set ch7 [$numbyte2hex ((($v7 << 6) + ($v6 >> 2)) & 0x7F) ]
:set ch8 [$numbyte2hex (( $v7 >> 1) & 0x7F) ]
:if (([:len $work] = 7) and ($ch8 != "00")) do={:set work "$ch1$ch2$ch3$ch4$ch5$ch6$ch7$ch8"
} else={ :if ( [:len $work] = 7 ) do={:set work "$ch1$ch2$ch3$ch4$ch5$ch6$ch7"
} else={ :if ( [:len $work] = 6 ) do={:set work "$ch1$ch2$ch3$ch4$ch5$ch6"
} else={ :if ( [:len $work] = 5 ) do={:set work "$ch1$ch2$ch3$ch4$ch5"
} else={ :if ( [:len $work] = 4 ) do={:set work "$ch1$ch2$ch3$ch4"
} else={ :if ( [:len $work] = 3 ) do={:set work "$ch1$ch2$ch3"
} else={ :if ( [:len $work] = 2 ) do={:set work "$ch1$ch2"
} else={ :if ( [:len $work] = 1 ) do={:set work "$ch1"
}}}}}}}}
:set output "$output$work"
:set position ($position + 7)
}
:return $output
}
[] > :put [$pdutogsm7 ("\C8\34\88\FE\06\05\D9\EC\50\28\04")] 486920746F20416C6C212121 :put [$HexGSM7toCP1252 [$pdutogsm7 ("\C8\34\88\FE\06\05\D9\EC\50\28\04")]] Hi to All!!! :put [$HexGSM7toCP1252 "486920746F20416C6C212121"] Hi to All!!! [] > :put [$pdutogsm7 ("\C8\34\88\FE\06\05\D9\EC\50\28")] Invalid PDU data, expected value not provided. [] > :put [$pdutogsm7 ("\C8\34\88\FE\06\05\D9\EC\50\28") "ignoreinvalid"] 486920746F20416C6C212121 :put [$HexGSM7toCP1252 "486920746F20416C6C2121"] Hi to All!!
[] > :put [$gsm7topdu ("*101#")] AA182C3602 /int lte at-chat lte1 input="AT+CUSD=1,\"$[$gsm7topdu ("*101#")]\",15" wait=yesNOTE: Some deice support directly the use of USSD code without coding it:
Thankswell done
Added the possibility to remove unwanted topics, like ipsec phase1 negotiation failedSend the only wanted Logs by Telegram messages:
[…]
Added the possibility to trim the length of the messagesSend the only wated Logs by Telegram messages:
[…]
:global ASCIItoCP1251toUNICODE do={
:local ascii "\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\
\10\11\12\13\14\15\16\17\18\19\1A\1B\1C\1D\1E\1F\
\20\21\22\23\24\25\26\27\28\29\2A\2B\2C\2D\2E\2F\
\30\31\32\33\34\35\36\37\38\39\3A\3B\3C\3D\3E\3F\
\40\41\42\43\44\45\46\47\48\49\4A\4B\4C\4D\4E\4F\
\50\51\52\53\54\55\56\57\58\59\5A\5B\5C\5D\5E\5F\
\60\61\62\63\64\65\66\67\68\69\6A\6B\6C\6D\6E\6F\
\70\71\72\73\74\75\76\77\78\79\7A\7B\7C\7D\7E\7F\
\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F\
\90\91\92\93\94\95\96\97\98\99\9A\9B\9C\9D\9E\9F\
\A0\A1\A2\A3\A4\A5\A6\A7\A8\A9\AA\AB\AC\AD\AE\AF\
\B0\B1\B2\B3\B4\B5\B6\B7\B8\B9\BA\BB\BC\BD\BE\BF\
\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF\
\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\
\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB\EC\ED\EE\EF\
\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF"
:local CP1251toUNICODE {"0000";"0001";"0002";"0003";"0004";"0005";"0006";"0007";"0008";"0009";"000A";"000B";"000C";"000D";"000E";"000F";
"0010";"0011";"0012";"0013";"0014";"0015";"0016";"0017";"0018";"0019";"001A";"001B";"001C";"001D";"001E";"001F";
"0020";"0021";"0022";"0023";"0024";"0025";"0026";"0027";"0028";"0029";"002A";"002B";"002C";"002D";"002E";"002F";
"0030";"0031";"0032";"0033";"0034";"0035";"0036";"0037";"0038";"0039";"003A";"003B";"003C";"003D";"003E";"003F";
"0040";"0041";"0042";"0043";"0044";"0045";"0046";"0047";"0048";"0049";"004A";"004B";"004C";"004D";"004E";"004F";
"0050";"0051";"0052";"0053";"0054";"0055";"0056";"0057";"0058";"0059";"005A";"005B";"005C";"005D";"005E";"005F";
"0060";"0061";"0062";"0063";"0064";"0065";"0066";"0067";"0068";"0069";"006A";"006B";"006C";"006D";"006E";"006F";
"0070";"0071";"0072";"0073";"0074";"0075";"0076";"0077";"0078";"0079";"007A";"007B";"007C";"007D";"007E";"007F";
"0402";"0403";"201A";"0453";"201E";"2026";"2020";"2021";"20AC";"2030";"0409";"2039";"040A";"040C";"040B";"040F";
"0452";"2018";"2019";"201C";"201D";"2022";"2013";"2014";"FFFD";"2122";"0459";"203A";"045A";"045C";"045B";"045F";
"00A0";"040E";"045E";"0408";"00A4";"0490";"00A6";"00A7";"0401";"00A9";"0404";"00AB";"00AC";"00AD";"00AE";"0407";
"00B0";"00B1";"0406";"0456";"0491";"00B5";"00B6";"00B7";"0451";"2116";"0454";"00BB";"0458";"0405";"0455";"0457";
"0410";"0411";"0412";"0413";"0414";"0415";"0416";"0417";"0418";"0419";"041A";"041B";"041C";"041D";"041E";"041F";
"0420";"0421";"0422";"0423";"0424";"0425";"0426";"0427";"0428";"0429";"042A";"042B";"042C";"042D";"042E";"042F";
"0430";"0431";"0432";"0433";"0434";"0435";"0436";"0437";"0438";"0439";"043A";"043B";"043C";"043D";"043E";"043F";
"0440";"0441";"0442";"0443";"0444";"0445";"0446";"0447";"0448";"0449";"044A";"044B";"044C";"044D";"044E";"044F"
}
:local string $1
:if (([:typeof $string] != "str") or ($string = "")) do={ :return "" }
:local lenstr [:len $string]
:local constr ""
:for pos from=0 to=($lenstr - 1) do={
:local unicode "0x$($CP1251toUNICODE->[:find $ascii [:pick $string $pos ($pos + 1)] -1]) "
:set constr "$constr$unicode"
}
:return $constr
}
:put [$ASCIItoCP1251toUNICODE ("\F2\E5\F1\F2")]
:global ASCIItoCP1251toUTF8 do={
:local ascii "\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\
\10\11\12\13\14\15\16\17\18\19\1A\1B\1C\1D\1E\1F\
\20\21\22\23\24\25\26\27\28\29\2A\2B\2C\2D\2E\2F\
\30\31\32\33\34\35\36\37\38\39\3A\3B\3C\3D\3E\3F\
\40\41\42\43\44\45\46\47\48\49\4A\4B\4C\4D\4E\4F\
\50\51\52\53\54\55\56\57\58\59\5A\5B\5C\5D\5E\5F\
\60\61\62\63\64\65\66\67\68\69\6A\6B\6C\6D\6E\6F\
\70\71\72\73\74\75\76\77\78\79\7A\7B\7C\7D\7E\7F\
\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F\
\90\91\92\93\94\95\96\97\98\99\9A\9B\9C\9D\9E\9F\
\A0\A1\A2\A3\A4\A5\A6\A7\A8\A9\AA\AB\AC\AD\AE\AF\
\B0\B1\B2\B3\B4\B5\B6\B7\B8\B9\BA\BB\BC\BD\BE\BF\
\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF\
\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\
\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB\EC\ED\EE\EF\
\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF"
:local CP1251toUTF8 {"00";"01";"02";"03";"04";"05";"06";"07";"08";"09";"0A";"0B";"0C";"0D";"0E";"0F";
"10";"11";"12";"13";"14";"15";"16";"17";"18";"19";"1A";"1B";"1C";"1D";"1E";"1F";
"20";"21";"22";"23";"24";"25";"26";"27";"28";"29";"2A";"2B";"2C";"2D";"2E";"2F";
"30";"31";"32";"33";"34";"35";"36";"37";"38";"39";"3A";"3B";"3C";"3D";"3E";"3F";
"40";"41";"42";"43";"44";"45";"46";"47";"48";"49";"4A";"4B";"4C";"4D";"4E";"4F";
"50";"51";"52";"53";"54";"55";"56";"57";"58";"59";"5A";"5B";"5C";"5D";"5E";"5F";
"60";"61";"62";"63";"64";"65";"66";"67";"68";"69";"6A";"6B";"6C";"6D";"6E";"6F";
"70";"71";"72";"73";"74";"75";"76";"77";"78";"79";"7A";"7B";"7C";"7D";"7E";"7F";
"D082";"D083";"E2809A";"D193";"E2809E";"E280A6";"E280A0";"E280A1";"E282AC";"E280B0";"D089";"E280B9";"D08A";"D08C";"D08B";"D08F";
"D192";"E28098";"E28099";"E2809C";"E2809D";"E280A2";"E28093";"E28094";"EFBFBD";"E284A2";"D199";"E280BA";"D19A";"D19C";"D19B";"D19F";
"C2A0";"D08E";"D19E";"D088";"C2A4";"D290";"C2A6";"C2A7";"D081";"C2A9";"D084";"C2AB";"C2AC";"C2AD";"C2AE";"D087";
"C2B0";"C2B1";"D086";"D196";"D291";"C2B5";"C2B6";"C2B7";"D191";"E28496";"D194";"C2BB";"D198";"D085";"D195";"D197";
"D090";"D091";"D092";"D093";"D094";"D095";"D096";"D097";"D098";"D099";"D09A";"D09B";"D09C";"D09D";"D09E";"D09F";
"D0A0";"D0A1";"D0A2";"D0A3";"D0A4";"D0A5";"D0A6";"D0A7";"D0A8";"D0A9";"D0AA";"D0AB";"D0AC";"D0AD";"D0AE";"D0AF";
"D0B0";"D0B1";"D0B2";"D0B3";"D0B4";"D0B5";"D0B6";"D0B7";"D0B8";"D0B9";"D0BA";"D0BB";"D0BC";"D0BD";"D0BE";"D0BF";
"D180";"D181";"D182";"D183";"D184";"D185";"D186";"D187";"D188";"D189";"D18A";"D18B";"D18C";"D18D";"D18E";"D18F"
}
:local string $1
:if (([:typeof $string] != "str") or ($string = "")) do={ :return "" }
:local lenstr [:len $string]
:local constr ""
:for pos from=0 to=($lenstr - 1) do={
:local utf ($CP1251toUTF8->[:find $ascii [:pick $string $pos ($pos + 1)] -1])
:local sym ""
:if ([:len $utf] = 2) do={:set sym "%$[:pick $utf 0 2]" }
:if ([:len $utf] = 4) do={:set sym "%$[:pick $utf 0 2]%$[:pick $utf 2 4]" }
:if ([:len $utf] = 6) do={:set sym "%$[:pick $utf 0 2]%$[:pick $utf 2 4]%$[:pick $utf 4 6]" }
:set constr "$constr$sym"
}
:return $constr
}
:put [$ASCIItoCP1251toUTF8 ("\F2\E5\F1\F2")]
:global ASCIItoCP1251toURLencode do={
:local ascii "\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\
\10\11\12\13\14\15\16\17\18\19\1A\1B\1C\1D\1E\1F\
\20\21\22\23\24\25\26\27\28\29\2A\2B\2C\2D\2E\2F\
\30\31\32\33\34\35\36\37\38\39\3A\3B\3C\3D\3E\3F\
\40\41\42\43\44\45\46\47\48\49\4A\4B\4C\4D\4E\4F\
\50\51\52\53\54\55\56\57\58\59\5A\5B\5C\5D\5E\5F\
\60\61\62\63\64\65\66\67\68\69\6A\6B\6C\6D\6E\6F\
\70\71\72\73\74\75\76\77\78\79\7A\7B\7C\7D\7E\7F\
\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F\
\90\91\92\93\94\95\96\97\98\99\9A\9B\9C\9D\9E\9F\
\A0\A1\A2\A3\A4\A5\A6\A7\A8\A9\AA\AB\AC\AD\AE\AF\
\B0\B1\B2\B3\B4\B5\B6\B7\B8\B9\BA\BB\BC\BD\BE\BF\
\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF\
\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\
\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB\EC\ED\EE\EF\
\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF"
:local CP1251toURLe {"00";"01";"02";"03";"04";"05";"06";"07";"08";"09";"0A";"0B";"0C";"0D";"0E";"0F";
"10";"11";"12";"13";"14";"15";"16";"17";"18";"19";"1A";"1B";"1C";"1D";"1E";"1F";
"+";"21";"22";"23";"24";"25";"26";"27";"28";"29";"2A";"2B";"2C";"-";".";"2F";
"0";"1";"2";"3";"4";"5";"6";"7";"8";"9";"3A";"3B";"3C";"3D";"3E";"3F";
"40";"A";"B";"C";"D";"E";"F";"G";"H";"I";"J";"K";"L";"M";"N";"O";
"P";"Q";"R";"S";"T";"U";"V";"W";"X";"Y";"Z";"5B";"5C";"5D";"5E";"_";
"60";"a";"b";"c";"d";"e";"f";"g";"h";"i";"j";"k";"l";"m";"n";"o";
"p";"q";"r";"s";"t";"u";"v";"w";"x";"y";"z";"7B";"7C";"7D";"~";"7F";
"D082";"D083";"E2809A";"D193";"E2809E";"E280A6";"E280A0";"E280A1";"E282AC";"E280B0";"D089";"E280B9";"D08A";"D08C";"D08B";"D08F";
"D192";"E28098";"E28099";"E2809C";"E2809D";"E280A2";"E28093";"E28094";"EFBFBD";"E284A2";"D199";"E280BA";"D19A";"D19C";"D19B";"D19F";
"C2A0";"D08E";"D19E";"D088";"C2A4";"D290";"C2A6";"C2A7";"D081";"C2A9";"D084";"C2AB";"C2AC";"C2AD";"C2AE";"D087";
"C2B0";"C2B1";"D086";"D196";"D291";"C2B5";"C2B6";"C2B7";"D191";"E28496";"D194";"C2BB";"D198";"D085";"D195";"D197";
"D090";"D091";"D092";"D093";"D094";"D095";"D096";"D097";"D098";"D099";"D09A";"D09B";"D09C";"D09D";"D09E";"D09F";
"D0A0";"D0A1";"D0A2";"D0A3";"D0A4";"D0A5";"D0A6";"D0A7";"D0A8";"D0A9";"D0AA";"D0AB";"D0AC";"D0AD";"D0AE";"D0AF";
"D0B0";"D0B1";"D0B2";"D0B3";"D0B4";"D0B5";"D0B6";"D0B7";"D0B8";"D0B9";"D0BA";"D0BB";"D0BC";"D0BD";"D0BE";"D0BF";
"D180";"D181";"D182";"D183";"D184";"D185";"D186";"D187";"D188";"D189";"D18A";"D18B";"D18C";"D18D";"D18E";"D18F"
}
:local string $1
:if (([:typeof $string] != "str") or ($string = "")) do={ :return "" }
:local lenstr [:len $string]
:local constr ""
:for pos from=0 to=($lenstr - 1) do={
:local urle ($CP1251toURLe->[:find $ascii [:pick $string $pos ($pos + 1)] -1])
:local sym $urle
:if ([:len $urle] = 2) do={:set sym "%$[:pick $urle 0 2]" }
:if ([:len $urle] = 4) do={:set sym "%$[:pick $urle 0 2]%$[:pick $urle 2 4]" }
:if ([:len $urle] = 6) do={:set sym "%$[:pick $urle 0 2]%$[:pick $urle 2 4]%$[:pick $urle 4 6]" }
:set constr "$constr$sym"
}
:return $constr
}
:put [$ASCIItoCP1251toURLencode ("test on Cyrillic is \F2\E5\F1\F2 (on CP1251)")]\F2\E5\F1\F2 = тест
:global CP1251to7BITbyGHOST do={
:local CP1251 "\00\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\
\10\11\12\13\14\15\16\17\18\19\1A\1B\1C\1D\1E\1F\
\20\21\22\23\24\25\26\27\28\29\2A\2B\2C\2D\2E\2F\
\30\31\32\33\34\35\36\37\38\39\3A\3B\3C\3D\3E\3F\
\40\41\42\43\44\45\46\47\48\49\4A\4B\4C\4D\4E\4F\
\50\51\52\53\54\55\56\57\58\59\5A\5B\5C\5D\5E\5F\
\60\61\62\63\64\65\66\67\68\69\6A\6B\6C\6D\6E\6F\
\70\71\72\73\74\75\76\77\78\79\7A\7B\7C\7D\7E\7F\
\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F\
\90\91\92\93\94\95\96\97\98\99\9A\9B\9C\9D\9E\9F\
\A0\A1\A2\A3\A4\A5\A6\A7\A8\A9\AA\AB\AC\AD\AE\AF\
\B0\B1\B2\B3\B4\B5\B6\B7\B8\B9\BA\BB\BC\BD\BE\BF\
\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF\
\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\
\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB\EC\ED\EE\EF\
\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF"
:local GHOST {"\00";"\01";"\02";"\03";"\04";"\05";"\06";"\07";"\08";"\09";"\0A";"\0B";"\0C";"\0D";"\0E";"\0F";
"\10";"\11";"\12";"\13";"\14";"\15";"\16";"\17";"\18";"\19";"\1A";"\1B";"\1C";"\1D";"\1E";"\1F";
"\20";"\21";"\22";"\23";"\24";"\25";"\26";"\27";"\28";"\29";"\2A";"\2B";"\2C";"\2D";"\2E";"\2F";
"\30";"\31";"\32";"\33";"\34";"\35";"\36";"\37";"\38";"\39";"\3A";"\3B";"\3C";"\3D";"\3E";"\3F";
"\40";"\41";"\42";"\43";"\44";"\45";"\46";"\47";"\48";"\49";"\4A";"\4B";"\4C";"\4D";"\4E";"\4F";
"\50";"\51";"\52";"\53";"\54";"\55";"\56";"\57";"\58";"\59";"\5A";"\5B";"\5C";"\5D";"\5E";"\5F";
"\60";"\61";"\62";"\63";"\64";"\65";"\66";"\67";"\68";"\69";"\6A";"\6B";"\6C";"\6D";"\6E";"\6F";
"\70";"\71";"\72";"\73";"\74";"\75";"\76";"\77";"\78";"\79";"\7A";"\7B";"\7C";"\7D";"\7E";"\7F";
"DJ";"GJ";"\82";"gj";"\84";"\85";"\86";"\87";"\80";"\89";"LJ";"\8B";"NJ";"KJ";"CJ";"DJ";
"dj";"\91";"\92";"\93";"\94";"\95";"\96";"\97";"\90";"\99";"lj";"\9B";"nj";"kj";"cj";"dj";
"\A0";"W";"w";"J";"\A4";"G";"\A6";"\A7";"YO";"\A9";"YE";"\AB";"\AC";"\AD";"\AE";"YI";
"\B0";"\B1";"I";"i";"g";"\B5";"\B6";"\B7";"yo";"#";"ye";"\BB";"j";"DZ";"dz";"yi";
"A";"B";"V";"G";"D";"E";"ZH";"Z";"I";"J";"K";"L";"M";"N";"O";"P";
"R";"S";"T";"U";"F";"X";"CZ";"CH";"SH";"SHH";"\"";"Y'";"'";"E'";"YU";"YA";
"a";"b";"v";"g";"d";"e";"zh";"z";"i";"j";"k";"l";"m";"n";"o";"p";
"r";"s";"t";"u";"f";"x";"cz";"ch";"sh";"shh";"\"";"y'";"'";"e'";"yu";"ya"
}
:local string $1
:if (([:typeof $string] != "str") or ($string = "")) do={ :return "" }
:local lenstr [:len $string]
:local constr ""
:for pos from=0 to=($lenstr - 1) do={
:set constr "$constr$($GHOST->[:find $CP1251 [:pick $string $pos ($pos + 1)] -1])"
}
:return $constr
}
:put [$CP1251to7BITbyGHOST ("\F2\E5\F1\F2")]
АБВГДЕ Ж ЗИЙКЛМНОПРСТУФХ Ц Ч Ш Щ Ъ Ы Ь Э Ю Я абвгде ж зийклмнопрстуфх ц ч ш щ ъ ы ь э ю я ABVGDE ZH ZIJKLMNOPRSTUFX CZ CH SH SHH " Y' ' E' YU YA abvgde zh zijklmnoprstufx cz ch sh shh " y' ' e' yu ya Ґ Ѓ Ђ Ё Є Ѕ І Ї Ј Љ Њ Ќ Ћ Ў Џ ґ ѓ ђ ё є ѕ і ї ј љ њ ќ ћ ў џ G GJ DJ YO YE DZ I YI J LJ NJ KJ CJ W DJ g gj dj yo ye dz i yi j lj nj kj cj w djThanks @Ca6ko for the suggestion of GOST 7.79-2000
There's no talking about it...It's time to hack the Router OS (scientifically speaking, reverse engineer it).
No... language misunderstand...Have you damaged 6 Mikrotik devices? It's hard to believe. What devices are these and how did this happen?
This truly is horrible. Between Anav and now Rex. This is a death blow basically to the forums for me. I can’t count how many times searches on google land me 8 times out of 10 to a solution or insight that swiftly lands me to a solution that came from either one of these two.Given the continued ingratitude of the forum's administrative staff, I will stop.
Did it cost so much to admit that, even if in good faith, the moderator had been wrong?
Someone will finally celebrate this event and be happy (is not one allusion for the administrative staff).
I feel sorry for the others, but they will no longer be able to count on my help.
Small note: unlike others who have already left in recent days, I will not delete any of my contributions on the forum.
As already written in another post, in another now deleted topic, I am too "fond" of the scripts I create to destroy them unnecessarily.
Surely there is someone who can get inspiration from it, or come in handy to someone.
Bad, bad news that so much knowledge is wasted and all these "feeling insulted" lost possibility to draw fully from the free sources of technical wisdom.Given the continued ingratitude of the forum's administrative staff, I will stop.
Did it cost so much to admit that, even if in good faith, the moderator had been wrong?
Someone will finally celebrate this event and be happy (is not one allusion for the administrative staff).I feel sorry for the others, but they will no longer be able to count on my help.
...
What you write is not true, and by deleting the posts, as you have already done, you erase the evidence.Very sad, that such basic ask like "can you please not use swear words" is taken as "ingratitude"
viewtopic.php?t=196072#p1039561Instead of blindly copying and pasting, try to understand what that command is for and why it was used that way.
I'm just happy that there are a lot of users who appreciated my work.I will not delete any of my contributions on the forum.
I am too "fond" of the scripts I create to destroy them unnecessarily.
Keep supporting the help vampires.This is because rextended, you never learn. What is happening here again? You start anotherr offtopic with all the complaining.
And I have to delete this post too, since it is off topic.
Well, this is indeed off-topic, it has nothing to do with script snippets.I can't continue to comment this in my topic, this on this topic is off-topic in... my topic.
While it got the wine... but c'mon, dutch impressionist art. And two door handles, although you are a security conscience guy. Always something wrong with these LLMsIt is made with artificial intelligence, since at least in this case imagination is useful...
I love Van Gogh...dutch impressionist art.
I hadn't noticed, but it would be nice...And two door handles
(The Amm0's one...This is the 100th post in this thread!![]()
Well, in honor of my 4,000th post (at time of writing), I decided to follow @ rextended's lead in consolidation. While back, I created a GitHub org called TIKOCI - https://github.com/tikoci - with that idea, but never got to the consolidation/writing part. So inspired by @rextended long work to keep track catalog scripts...I finally at started the process.(The Amm0's one...This is the 100th post in this thread!![]()
)
I didn't quite understand the meaning, because of the language, but if what I understood is right:I guess everything is relative.
Just used one of your little gems as a response to someone having trouble searching for host-names (which can be case "anything")Case INsensitive search (on example on comment field)
viewtopic.php?t=191504#p971246