Convert unicode to ascii?

Anyone know a simple way to convert a unicode string to ASCII within an iRule?

I was hoping that [encoding convertfrom unicode $item] from the TCL world would work, but this doesn’t seem to be available for use in iRules.

In order to be usable in the new 10.1 tables feature, I need to convert a unicode field to ASCII so I can use it as a subtable name.

So without [encoding convertfrom unicode $variable], the following will do the job:

foreach i [ split $variable ""] {  
          scan $i %c c 
          if {$c>1} { 
              append variable_convert $i 
          } elseif {$c<128} { 
              set variable_convert $ntlm_host_convert 
          } else { 
              append variable_convert \\u[format %04.4X $c] 
          } 
       } 
       set variable $variable_convert

This is really kind of a hack, but it works most of the time. If anyone from PD is reading this, please please please unblock the [encoding] command for iRule use (at least the convertto and convertfrom one)!!