Page 1 of 1
Unicode to quoted-printable conversion
Posted: Sat Aug 11, 2012 9:21 pm
by snm
Does it exist any function or external which converts unicode text to "quoted-printable" format?
It should substitute non latin and some special chars to "=XX", "=" to "=3D" etc, as well as split long lines to max 70 chars per line with "=" at the end.
Marek
Re: Unicode to quoted-printable conversion
Posted: Sun Aug 12, 2012 11:05 am
by Mark
Hi,
It is quite simple to write such a function in LiveCode.
Wikipedia contains all the info you need.
Kind regards,
Mark
Re: Unicode to quoted-printable conversion
Posted: Sun Aug 12, 2012 11:56 am
by shaosean
I got one, will post in a couple of days if you can wait for me to find it..
Re: Unicode to quoted-printable conversion
Posted: Sun Aug 12, 2012 12:30 pm
by snm
Thanks a lot Shaosean. I can wait few days, as it's only small part of my project.
Marek
Re: Unicode to quoted-printable conversion
Posted: Tue Aug 14, 2012 11:25 am
by snm
Hi Saosean,
Did you find it?
Marek
Re: Unicode to quoted-printable conversion
Posted: Tue Aug 14, 2012 11:38 am
by shaosean
Few more terabytes to search through.. I should really sort/catalogue my files better, but this gives me a bit of a challenge I guess

Re: Unicode to quoted-printable conversion
Posted: Tue Aug 14, 2012 1:55 pm
by snm
Please try to give it some priority if it's possible. I count on your help very much.
Marek.
Re: Unicode to quoted-printable conversion
Posted: Wed Aug 15, 2012 5:41 am
by shaosean
It does not split the lines though, but should be easy enough to do, just make sure to do it at the equal sign so as not to split an encoded char..
Code: Select all
on mouseUp
put quotedPrintableFromUnicode(the unicodeText of field 1)
end mouseUp
function quotedPrintableFromUnicode pData
local tFirstByteFlag -- bool, flag if we're on the first or second byte of a two byte char
local tOneByteChar -- char, repeat loop var, current one-byte character in the saBody["text"] variable
local tOneByteChar2 -- char, repeat loop var, current one-byte character in the tTwoByteCharDecoded variable
local tTwoByteChar -- char, current two-byte character (created by placing two tOneByteChar vars together)
local tTwoByteCharDecoded -- str, conversion of tTwoByteChar to UTF8
local tOneByteCharConverted -- str, conversion of tOneByteChar2 to quoted-printable
local tDataOut -- str, encoded data
local tDataInLine
local tDataInLine2
--- encode the plain text body part
put TRUE into tFirstByteFlag
repeat for each char tOneByteChar in pData
if (tFirstByteFlag) then
put tOneByteChar into tTwoByteChar
put FALSE into tFirstByteFlag
next repeat
else
put tOneByteChar after tTwoByteChar
put TRUE into tFirstByteFlag
end if
set the useUnicode to TRUE
if (charToNum(tTwoByteChar) > 127) then
put uniDecode(tTwoByteChar, "UTF8") into tTwoByteCharDecoded
repeat for each char tOneByteChar2 in tTwoByteCharDecoded # v101: changed tOneByteChar to tOneByteChar2 to lessen confusion: Jan Decroos
get binaryDecode("H2", tOneByteChar2, tOneByteCharConverted) # v101: changed tOneByteChar to tOneByteChar2 to lessen confusion: Jan Decroos
put "=" & toUpper(tOneByteCharConverted) after tDataOut
end repeat
else
put uniDecode(tTwoByteChar, "UTF8") after tDataOut
end if
end repeat
return tDataOut
end quotedPrintableFromUnicode
Re: Unicode to quoted-printable conversion
Posted: Wed Aug 15, 2012 9:59 am
by snm
Thanks a lo Saosean. It's working great. You helped me much.
I owe you few hours of work or some beer in next future.
Marek
Re: Unicode to quoted-printable conversion
Posted: Wed Aug 15, 2012 10:27 am
by shaosean
I take PayPal as well as bags of cash left at the door

Re: Unicode to quoted-printable conversion
Posted: Wed Aug 15, 2012 11:22 am
by snm
So I'm starting to collect cash. What kind of bag do you prefer?
Re: Unicode to quoted-printable conversion
Posted: Wed Aug 15, 2012 11:51 am
by shaosean
Not too picky, I usually just use the bags afterwards to make beds for all the stray cats that live in my bedroom
