Forum Discussion
beefy80
Nimbostratus
Jun 05, 2014Convert string with parity to standard ASCII
Hello
I need to convert a string that has Even Parity added to it to printable ascii. However I am having problems in getting this working. Can anyone advise on how to achieve this in an iRule.
Thanks
James
2 Replies
- James_Deucker_2Historic F5 Account
Here's the TCL that will do the encode
set plain_str "james was here ok" puts "Plain String '$plain_str'" set even_parity "" foreach c [split $plain_str ""] { append even_parity [format %c [expr { ( [scan $c %c] & 127 ) + (!([scan $c %c] & 1)<<7)}]]} puts "Even Parity '$even_parity'"And here's the decode:
set stripped_parity "" foreach c [split $even_parity ""] { append stripped_parity [format %c [expr {[scan $c %c] & 127}]]} puts "Stripped Parity '$stripped_parity'"Output:
Plain String 'james was here ok' Even Parity 'êames was èeòe ok' Stripped Parity 'james was here ok' - beefy80
Nimbostratus
James, Thank you for this I have been trying all sorts of variations to resolve this I wasn't far off getting it right either. Thanks again.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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