Decoding "quoted-printable" -- Help needed -- Solved

R.H. roland.huettmann at
Thu Nov 14 07:44:36 EST 2019

For those interested:

With the help of a privately received message hinting at a solution used
prior to LC7 I was able to construct the required functions for LC 7 and

I must say that I am not really aware of all the many functions LiveCode
presents, I did not even know about baseConvert() before doing a lot of
research. I guess, each of us must go through all the commands and
functions LC provides and study them. It is difficult to find when not
knowing how and what to search for. Also, I had to try to understand what
codepoints are.

Here I am not using the actual quoted-printable format of codepoints in Hex
presentation each with a equal sign "=" as a prefix. That is easy to
retrieve or construct using LiveCode chunk expressions. Instead I am using
comma delimited items.

// The encoding priot to LC7 according to Mark (still works even today)
-- put unidecode(uniencode("e","english"),"UTF8") into x
-- put chartonum(char 1 of x) && chartonum(char 2 of x) into y

// Encoding and decoding UTF-8 for quoted-printable chars (as they may
appear in certain e-mail parts)
set the itemdelimiter to ","
put "€" into tChar -- Using the Euro symbol which is encoded with 3
codepoints (there can be up to 4 for quoted-printable).

// Encode a UTF-8 character to a quoted-printable ASCII encoding
put textEncode( tChar ,"UTF-8") into tCodedChar
repeat for each codePoint tCodePoint in tCodedChar
   put BaseConvert ( codePointToNum (tCodePoint) , 10 , 16 ) &"," after
end repeat
delete last char of tEncoded
put tEncoded &CR into msg -- just for testing

// Decode a quoted-printable ASCII string to UTF-8
put empty into tDecoded
repeat for each item tItem in tEncoded
   put numToCodePoint ( BaseConvert ( tItem , 16, 10 ) ) after tDecoded
end repeat
put textDecode (tDecoded , "UTF-8") after msg -- just for testing

// Result in message box
-- E2,201A,AC -- In actual quoted-printable that would be: "=E2=201A=AC"
and our items must be converted accordingly
-- €


More information about the use-livecode mailing list