how to uniencode text for VCard v. 3.0? [2]

Sarah Reichelt sarah.reichelt at gmail.com
Wed Jun 11 16:55:28 EDT 2008


> To avoid converting the entire string to UTF8 (when it's only accented chars
> that need it), what I have done is store the decimal/UTF8/Hex character
> equivalents in a customproperty, then run each element value through this
> encoder...
>
> function UTF8.encode tStr
>  put numtochar(13)&numtochar(10) into tCRLF
>  set the itemDel to TAB
>  set the caseSensitive to "TRUE"
>  repeat for each char L in tStr
>   get chartonum(L)
>   if it>=160 then
>     get lineOffset(CR&it&TAB, CR&the UTF8Table of this stack) --| Get the
> table line
>     if it >0 then
>       if VCVERS="2.1" then put toUpper(item 3 of line it of the UTF8Table of
> this stack) after stdout --| Use UTF8
>       else put toUpper(item 2 of line it of the UTF8Table of this stack)
> after stdout --| Use HEX
>     end if
>   else put L after stdout
>  end repeat
>  replace "\" with "\\" in stdout
>  replace "," with "\," in stdout
>  replace ";" with "\;" in stdout
>  replace CR with "=0D=0A" in stdout --| v2.1 WAB
>  return stdout
> end UTF8.encode
>
> If the above looks of interest, let me know and I'll send you the look-up
> table of character equivalents .

Hi Hugh,

This sounds extremely useful and I would be really grateful for a copy
of your character table too please.

Many thanks,
Sarah



More information about the use-livecode mailing list