05-29-2017, 08:14 AM
An Android system produces contacts as .vcf files with encoding ''CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE''. I wrote a simple routine to convert this .vcf file to a readable in Windows XP format. It seems that the output file is written in a readable form. However, when I open it as .vcf file it is still in a not readable form. Any advice is mostly welcome. Many thanks in advance.
Macro temp03
Trigger SF9
Member function str.QuotedPrintableEncodingUtf_8Q
Macro temp03
Trigger SF9
str sinp="C:\tmp\pst\vcard.vcf"
str sout="C:\tmp\pst\vcardo.vcf"
str stxt stxto
out
stxt.getfile(sinp)
str s sc
int j
str sf=";CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:"
int l=sf.len
foreach s stxt
,j=find(s sf)
,if j>0
;,,out s
,,sc.get(s j+l)
;,,out sc
,,sc.QuotedPrintableEncodingUtf_8Q(1)
,,_s.left(s j)
,,s.from(_s ":" sc)
,,out s
,stxto.formata("%s[]" s)
;out stxto
stxto.setfile(sout)
out stxto
_s.getfile(sout)
out _s
Member function str.QuotedPrintableEncodingUtf_8Q
;/
function$ action [$charset] ;;action: 0 encode, 1 decode - Charset 0 suitable for =?utf-8?Q?
;Encodes or decodes text of this variable using quoted-printable encoding.
;Returns self.
;Example :
;str s
;;From: =?UTF-8?Q?=22=CE=9C=CF=80=CE=B1=CE=BB=CE=BB=CE=AE=CF=82_=CE=91=CE=BB=CE?= =?UTF-8?Q?=AD=CE=BE=CE=B1=CE=BD=CE=B4=CF=81=CE=BF=CF=82=22?= <aballis@central.ntua.gr>
;s="=22=CE=9C=CF=80=CE=B1=CE=BB=CE=BB=CE=AE=CF=82_=CE=91=CE=BB=CE=AD=CE=BE=CE=B1=CE=BD=CE=B4=CF=81=CE=BF=CF=82=22 <aballis@central.ntua.gr>" ;; Recipient
;out s.QuotedPrintableEncodingBeeSES(1)
;s="=CE=95=CE=98=CE=9D=CE=99=CE=9A=CE=9F_=CE=9C=CE=95=CE=A4=CE=A3" ;; subject
;out s.QuotedPrintableEncodingBeeSES(1)
if(!this.len) ret this
MailBee.Message m._create
sel action
,case 0
,m.BodyText=this ;;does not respond to charset etc. Always uses default codepage/charset of current user.
,_s=m.RawBody
,
,case 1
,m.RawBody=_s.from(m.RawBody this)
,m.BodyEncoding=3 ;;at first encode base64, because if 0 (no encoding), wraps lines
,_s=m.RawBody
,
,case else ret this
;remove headeds
int i=find(_s "[][]")
if i>=0
,i+4
,if(action=0) this.get(_s i)
,else this.decrypt(4 _s+i); if(_unicode and charset) this.ConvertEncoding(0 _unicode)
err+ end _error
ret this