|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
How to "decode" e-mail subject ?
I'm having trouble finding ways to convert a email subject from utf-8 to "plain text"WebSite CFTalk 04/07/09 02:23 P This:B?W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl?=Alan Rother 04/07/09 02:47 P Alright, ok :)WebSite CFTalk 04/07/09 04:06 P WebSite CFTalk wrote:Paul Hastings 04/07/09 10:15 P Thank you PaulWebSite CFTalk 04/14/09 10:34 A > This:B?W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl?=Paul Vernon 04/07/09 11:26 P Alan Rother wrote:Paul Hastings 04/07/09 10:09 P > This:B?W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl?=Paul Vernon 04/07/09 11:18 P >> Hi Paul,Abid Islam 11/22/11 04:48 A Thank you Paul,WebSite CFTalk 04/08/09 04:54 A I'm having trouble finding ways to convert a email subject from utf-8 to "plain text" Subject: (Copied from the mail header in outlook) =?utf-8?B?W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl?= =?utf-8?B?ZyBnb2QgcMOlc2tl?= In Outlook this is translated to: [Videresendt fra WS Support] PayEx ønsker deg god påske Anyone care to show me how it's done? Thanks, Helge :) This:B?W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl?= =?utf-8?B?ZyBnb2QgcMOlc2tl?= Is not UTF8 encoding, this is some sort of Outlook "crap" UTF-8 Encoding is not an encryption schema, it's a file formatting encoding. It usually renders exactly as plain text. =] ----- Excess quoted text cut - see Original Post for more ----- Alright, ok :) But still, how do I convert it into something readable ? Helge :) This:B?W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl?= =?utf-8?B?ZyBnb2QgcMOlc2tl?= Is not UTF8 encoding, this is some sort of Outlook "crap" UTF-8 Encoding is not an encryption schema, it's a file formatting encoding. It usually renders exactly as plain text. =] ----- Excess quoted text cut - see Original Post for more ----- WebSite CFTalk wrote: > But still, how do I convert it into something readable ? <cfscript> y='W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl'; x=toString(toBinary(y)); writeOutput(x); </cfscript> you should get something like: [Videresendt fra WS Support] PayEx ønsker de i'll leave parsing the MIME encoded subject to you... Thank you Paul If anyone is interested: A bit "dirty" but this worked for me..: <cfset codedstring="=?utf-8?B?W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl?= =?utf-8?B?ZyBnb2QgcMOlc2tl?="> <cfset cleanstring =""> <cfset a=#replacenocase(codedstring, '=?utf-8?B?','', 'all')#> <cfloop list="#a#" index="lid" delimiters=" "> <cfset cleanstring='#cleanstring#' & '#toString(toBinary(LID))#'> </cfloop> <cfoutput>#cleanstring#</cfoutput> Helge WebSite CFTalk wrote: > But still, how do I convert it into something readable ? <cfscript> y='W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl'; x=toString(toBinary(y)); writeOutput(x); </cfscript> you should get something like: [Videresendt fra WS Support] PayEx ønsker de i'll leave parsing the MIME encoded subject to you... > This:B?W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl?= > =?utf-8?B?ZyBnb2QgcMOlc2tl?= > I missed something... It's not quoted printable, it's binary encoded. Q for quoted-printable and B for binary. You need to look for =?B? Or =?Q? At the beginning of the string. If its =?B? Then take everything between =?B? and ?= and base64 decode it. W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl decodes as [Videresendt fra WS Support] PayEx ønsker de ZyBnb2QgcMOlc2tl decodes as g god påske To handle all eventualities, you will still need a quoted-printable decoder to handle subjects that start with =?Q? Alan Rother wrote: > This:B?W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl?= > =?utf-8?B?ZyBnb2QgcMOlc2tl?= > > Is not UTF8 encoding, this is some sort of Outlook "crap" no, it's not outlook "crap". that's MIME encoding: "=?charset?encoding?encoded text?=" so that subject text is in utf-8 using base64 encoding (the ?B? bit). > UTF-8 Encoding is not an encryption schema, it's a file formatting encoding. and no, utf-8 is not "a file formatting encoding". ----- Excess quoted text cut - see Original Post for more ----- Actually, it isn't Outlook "crap" it is standards compliant RFC Quoted-printable content and the utf-8 info is telling you that the quoted printable text once decoded will be in the utf-8 encoding and should be treated as such. It is done in this way so it can be sent to mail systems that still have to support 7-bit encoding mechanisms. You'll need to look at finding a Quoted-Printable decoder for CF. I have one built into my CFX tags but they are written in Delphi so not really much help for you at the moment. Paul >> Hi Paul, I am working in delphi 7, and I am done with utf-8?B? decoding, now i need to decode utf-8?Q? Please provide me the code for decoder in Delphi. thanks in advance ----- Excess quoted text cut - see Original Post for more ----- Thank you Paul, That gave me something to work on. Helge > This:B?W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl?= > =?utf-8?B?ZyBnb2QgcMOlc2tl?= > I missed something... It's not quoted printable, it's binary encoded. Q for quoted-printable and B for binary. You need to look for =?B? Or =?Q? At the beginning of the string. If its =?B? Then take everything between =?B? and ?= and base64 decode it. W1ZpZGVyZXNlbmR0IGZyYSBXUyBTdXBwb3J0XSBQYXlFeCDDuG5za2VyIGRl decodes as [Videresendt fra WS Support] PayEx ønsker de ZyBnb2QgcMOlc2tl decodes as g god påske To handle all eventualities, you will still need a quoted-printable decoder to handle subjects that start with =?Q?
|
May 20, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||