Forum Discussion
ims_243721
Nimbostratus
Jan 15, 2016TCL encoding command not accepted
I need to encode variable with unicode
set uni_msg [URI::query [HTTP::uri] "msg"]
set en_msg [encoding convertto unicode $uni_msg]
Seems that F5 interpreter not accepting encoding TCL comm...
Kai_Wilke
MVP
Jan 17, 2016Hi Ims,
the custom char map would then look like this...
Example1:
when HTTP_REQUEST {
set uri_input "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
set input [URI::decode $uri_input]
set output [string trim [string map {
"a" " 0x13" "b" " 0x14" "c" " 0x25" "d" " 0x26" "e" " 0x13" "f" " 0x14" "g" " 0x25" "h" " 0x26"
"i" " 0x13" "j" " 0x14" "k" " 0x25" "l" " 0x26" "m" " 0x13" "n" " 0x14" "o" " 0x25" "p" " 0x26"
"q" " 0x13" "r" " 0x14" "s" " 0x25" "t" " 0x26" "u" " 0x13" "v" " 0x14" "w" " 0x25" "x" " 0x26"
"y" " 0x13" "z" " 0x14"
"A" " 0x13" "B" " 0x14" "C" " 0x25" "D" " 0x26" "E" " 0x13" "F" " 0x14" "G" " 0x25" "H" " 0x26"
"I" " 0x13" "J" " 0x14" "K" " 0x25" "L" " 0x26" "M" " 0x13" "N" " 0x14" "O" " 0x25" "P" " 0x26"
"Q" " 0x13" "R" " 0x14" "S" " 0x25" "T" " 0x26" "U" " 0x13" "V" " 0x14" "W" " 0x25" "X" " 0x26"
"Y" " 0x13" "Z" " 0x14"
} $input ]]
}
If this technique clutters your code too much, then you could also outsource the functionality into a TCL procedure. But it would cause some added overhead for the procedure housekeeping...
Example2:
when HTTP_REQUEST {
set uri_input "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
set input [URI::decode $uri_input]
set output [call YOUR_RULE_NAME::MY_CHAR_MAP $input]
}
proc MY_CHAR_MAP { string } {
return [string trim [string map {
"a" " 0x13" "b" " 0x14" "c" " 0x25" "d" " 0x26" "e" " 0x13" "f" " 0x14" "g" " 0x25" "h" " 0x26"
"i" " 0x13" "j" " 0x14" "k" " 0x25" "l" " 0x26" "m" " 0x13" "n" " 0x14" "o" " 0x25" "p" " 0x26"
"q" " 0x13" "r" " 0x14" "s" " 0x25" "t" " 0x26" "u" " 0x13" "v" " 0x14" "w" " 0x25" "x" " 0x26"
"y" " 0x13" "z" " 0x14"
"A" " 0x13" "B" " 0x14" "C" " 0x25" "D" " 0x26" "E" " 0x13" "F" " 0x14" "G" " 0x25" "H" " 0x26"
"I" " 0x13" "J" " 0x14" "K" " 0x25" "L" " 0x26" "M" " 0x13" "N" " 0x14" "O" " 0x25" "P" " 0x26"
"Q" " 0x13" "R" " 0x14" "S" " 0x25" "T" " 0x26" "U" " 0x13" "V" " 0x14" "W" " 0x25" "X" " 0x26"
"Y" " 0x13" "Z" " 0x14"
} $string ]]
}
Cheers, Kai
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects