By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,364 Members | 1,671 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,364 IT Pros & Developers. It's quick & easy.

decode base64 string

P: n/a
Dear sir,

I need to decode base64 encoded email.

I used below function but it does not work correctly, especially when I need
to decode some Characters like Chinese,

Can some one point out what I did wrong here? Thanks.

Public Function DecodeBase64(ByVal strInput As String) As String

Dim ReturnByte As Byte()

ReturnByte = System.Convert.FromBase64String(strInput)

Dim ReturnString As String

ReturnString = System.Text.Encoding.UTF8.GetString(ReturnByte)

Return ReturnString

End Function
--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com

Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
It's possible that the string was originally encoded using another codepage
or as Unicode, instead of UTF8.
Try some of the other System.Text.Encoding values.

-Rob Teixeira [MVP]

"Guoqi Zheng" <no@sorry.nl> wrote in message
news:u3**************@TK2MSFTNGP12.phx.gbl...
Dear sir,

I need to decode base64 encoded email.

I used below function but it does not work correctly, especially when I need to decode some Characters like Chinese,

Can some one point out what I did wrong here? Thanks.

Public Function DecodeBase64(ByVal strInput As String) As String

Dim ReturnByte As Byte()

ReturnByte = System.Convert.FromBase64String(strInput)

Dim ReturnString As String

ReturnString = System.Text.Encoding.UTF8.GetString(ReturnByte)

Return ReturnString

End Function
--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com

Nov 21 '05 #2

P: n/a
This a base64 string inside an email message. How can I determine what
encoding they used originally??
I need a function which able to decode any base64 encoded string, otherwise,
I have problem.

--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com

"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
It's possible that the string was originally encoded using another codepage or as Unicode, instead of UTF8.
Try some of the other System.Text.Encoding values.

-Rob Teixeira [MVP]

"Guoqi Zheng" <no@sorry.nl> wrote in message
news:u3**************@TK2MSFTNGP12.phx.gbl...
Dear sir,

I need to decode base64 encoded email.

I used below function but it does not work correctly, especially when I

need
to decode some Characters like Chinese,

Can some one point out what I did wrong here? Thanks.

Public Function DecodeBase64(ByVal strInput As String) As String

Dim ReturnByte As Byte()

ReturnByte = System.Convert.FromBase64String(strInput)

Dim ReturnString As String

ReturnString = System.Text.Encoding.UTF8.GetString(ReturnByte)

Return ReturnString

End Function
--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com


Nov 21 '05 #3

P: n/a
One of the headers in the email tells you the content type, and if it's
text, will most likely also tell you what charset or codepage was used to
encode it. You must use this charset or codepage to decode the body (or part
of the body for multi-part emails).

I'm not an expert on email protocols, so you should look up the various RFC
documents to get a clear picture of what headers you need to look for, and
what format the messages will be in.

-Rob Teixeira [MVP]

"Guoqi Zheng" <no@sorry.nl> wrote in message
news:uq**************@TK2MSFTNGP12.phx.gbl...
This a base64 string inside an email message. How can I determine what
encoding they used originally??
I need a function which able to decode any base64 encoded string, otherwise, I have problem.

--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com

"Rob Teixeira [MVP]" <RobTeixeira@@msn.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
It's possible that the string was originally encoded using another

codepage
or as Unicode, instead of UTF8.
Try some of the other System.Text.Encoding values.

-Rob Teixeira [MVP]

"Guoqi Zheng" <no@sorry.nl> wrote in message
news:u3**************@TK2MSFTNGP12.phx.gbl...
Dear sir,

I need to decode base64 encoded email.

I used below function but it does not work correctly, especially when
I need
to decode some Characters like Chinese,

Can some one point out what I did wrong here? Thanks.

Public Function DecodeBase64(ByVal strInput As String) As String

Dim ReturnByte As Byte()

ReturnByte = System.Convert.FromBase64String(strInput)

Dim ReturnString As String

ReturnString = System.Text.Encoding.UTF8.GetString(ReturnByte)

Return ReturnString

End Function
--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com



Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.