473,857 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

decode base64 string

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(By Val strInput As String) As String

Dim ReturnByte As Byte()

ReturnByte = System.Convert. FromBase64Strin g(strInput)

Dim ReturnString As String

ReturnString = System.Text.Enc oding.UTF8.GetS tring(ReturnByt e)

Return ReturnString

End Function
--
Kind regards

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

Nov 21 '05 #1
3 4103
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.Enc oding values.

-Rob Teixeira [MVP]

"Guoqi Zheng" <no@sorry.nl> wrote in message
news:u3******** ******@TK2MSFTN GP12.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(By Val strInput As String) As String

Dim ReturnByte As Byte()

ReturnByte = System.Convert. FromBase64Strin g(strInput)

Dim ReturnString As String

ReturnString = System.Text.Enc oding.UTF8.GetS tring(ReturnByt e)

Return ReturnString

End Function
--
Kind regards

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

Nov 21 '05 #2
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@@m sn.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.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.Enc oding values.

-Rob Teixeira [MVP]

"Guoqi Zheng" <no@sorry.nl> wrote in message
news:u3******** ******@TK2MSFTN GP12.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(By Val strInput As String) As String

Dim ReturnByte As Byte()

ReturnByte = System.Convert. FromBase64Strin g(strInput)

Dim ReturnString As String

ReturnString = System.Text.Enc oding.UTF8.GetS tring(ReturnByt e)

Return ReturnString

End Function
--
Kind regards

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


Nov 21 '05 #3
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******** ******@TK2MSFTN GP12.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@@m sn.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.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.Enc oding values.

-Rob Teixeira [MVP]

"Guoqi Zheng" <no@sorry.nl> wrote in message
news:u3******** ******@TK2MSFTN GP12.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(By Val strInput As String) As String

Dim ReturnByte As Byte()

ReturnByte = System.Convert. FromBase64Strin g(strInput)

Dim ReturnString As String

ReturnString = System.Text.Enc oding.UTF8.GetS tring(ReturnByt e)

Return ReturnString

End Function
--
Kind regards

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



Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2230
by: Damir Hakimov | last post by:
Hi *! I found a strange bug in base64.encode and decode, when I try to encode - decode a file 1728512 bytes lenth. Is somebody meet with this? I don't attach the file because it big, but can send to private. Which solution for transfer file (binary data) via string-only object? Damir.
3
18505
by: Steve Montague | last post by:
I need to decode a base64 image and display it in a PictureBox control. Currently I get an "Invaild character in a Base-64 string." error, so not sure if a bad file or bad code, I have: byte arrBytes = new Byte; // read the file from disk System.IO.FileStream fs = System.IO.File.OpenRead("../../Photo.jpg"); arrBytes = new byte; fs.Read(arrBytes, 0, (int)fs.Length - 1);
1
2164
by: Guoqi Zheng | last post by:
Hi, Any one has a code example of how to decode base64 string? I used below function but it does not work correctly, especially when I need to decode some Characters like Chinese, Can some one give an example or point out what I did wrong here? Thanks.
7
9018
by: jtfaulk | last post by:
I need to encode some information on the server side using ASP.NET with C#; sending via HTTP to a client side application, that needs to be decoded in an MFC C++ application. I'm not sure if I can encode something using: C#: System.Security.Cryptography (to encode) and
5
8620
by: robert.bull | last post by:
Hello - I am currently working on a project in classic ASP where I receive an XML file that contains an encoded base64 string that I need to do the following to: 1. Decode the base64 string for a binary write 2. Insert the decoded string into SQL Server for later binary writes I have searched the web but I cannot find anything that works. There are many decode functions available but I cannot insert the results
3
18860
by: Kuldeep | last post by:
Hi All, Could you please give me some guidelines on dealing with Base64 encoded string. The actual purpose is to decode Base64 Encoded string and stream the data to a browser so that it can be viewed in a web application Regards, Kuldeep
1
1558
by: Mr. T | last post by:
Hello, i'm developing an application where i want to use the login auth application provided by our organisation. However i'm a bit stuck on processing the auth string i get back. The way it works is as follows: people go to a general login form, where they type in their username and password. they hit login and the login authentication app looks if the login is ok.
1
3582
by: Eric S. Johansson | last post by:
I'm having a problem (Python 2.4) converting strings with random 8-bit characters into an escape form which is 7-bit clean for storage in a database. Here's an example: body = meta.encode('unicode-escape') when given an 8-bit string, (in meta), the code fragment above yields the error below. 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in range(128)
3
3793
by: d-fan | last post by:
void decodebio( unsigned char *encbuf, unsigned char * decbuf, int destbuf ) { /* Read Base64 encoded data from standard input and write the decoded data to standard output: */ BIO *b64, *bio ; long i ; char buffer ; memset(buffer, 0, 512) ;
0
9767
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10807
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10394
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9549
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7104
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5774
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5967
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.