Escaping foreign characters

Post Reply
sabety
Posts: 76
Joined: Wed Dec 06, 2000 7:11 am

Escaping foreign characters

Post by sabety »

I need to escape only characters above 127, such as french characters, that appear arbitrarily in english text. I don't want to do this manually and all the escapement formats escape everything, including HTML tags in the data.
User avatar
Kai
Site Admin
Posts: 1271
Joined: Tue Apr 25, 2000 1:27 pm

Escaping foreign characters

Post by Kai »

There is no format code to escape characters 160 and above (the ISO-8859 foreign chars), only 128 through 159. You would have to manually escape such characters, using <fmtcp sandcall>. This code will escape $string's hit-bit characters:

<A NAME=cb hit>
<strfmt "%U" $hit> <!-- URL-encode to convert to hex -->
<substr $ret 1 -1> <!-- strip the leading `%' -->
<fmt "&#x%s;" $ret> <!-- print as HTML escape -->
</A>

<A NAME=main>
<fmtcp sandcall noesc "[\x80-\xFF]" "cb">
<sb>$string</sb>
</A>
Post Reply