Forum Discussion
Is it possible to replace extended ASCII characters in URI to UTF-8 character set
This is perhaps not the most optimal solution, but it does technically work. Only providing the framework here for your review:
when RULE_INIT {
set c {This is a Test° on Tuesd©y}
set c {This is a Test on Tuesday}
if { [set matchTuples [regexp -all -inline {&\d+;} $c]] ne "" } {
foreach x $matchTuples {
set num [findstr $x "&" 2 ";"]
if { [expr { ( $num >= 80 ) && ( $num <= 191 ) }] } {
set html "%C2%[format %X $num]"
set c [string map "$x $html" $c]
}
}
}
log local0. "c = $c"
}
So basically, c would be your input URL. iRules automatically convert extended ascii characters to decimal (ex. ° = &176;), so if the regexp finds any "&\d+;" matches, those will be inserted into a list, the list converts each decimal to HEX, appends %C2 for extended ascii characters between 80 and 191, and then replaces the decimal encoding in the original string with the new HTML encoding.
This example only handles the extended ascii characters between 80 and 191. If the decimal value is between 192 and 255, you'd append "%C3".
Recent Discussions
Related Content
* 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