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

Hugh Senior FlexibleLearning at tiscali.co.uk
Wed Jun 11 13:24:54 EDT 2008


Hi Klaus,

I just replied totally incorrectly to your UTF-8 query! Must be having a bad 
hair day... My apologies.

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 .

/H 




More information about the use-livecode mailing list