Hi,
in my quest to properly display email messages I have overcome the problem
of decoding strings like
"=?GB2312?B?s8q 5q8u+vq3A7aGiss bO8bK/w8W1xNK7t+LQxQ= =?="
(which appears to be an 'encoded-word' as is explained in rfc2047), by using
Convert.FromBas e64String as Stefen kindly suggested (my post from
yesterday).
The body part of the same message however claims also to be of charset
GB2312, but certainly is not base64 encoded. It contains text in which (what
should be) Chinese and ASCII characters mixed like:
Vz@m#:UEP!=c 0724398252418
;rE_MAIL#:le*** ***@1647753.com
I tried to use the conversion function as suggested by Morton (thank you for
the code) but this doesn't produce chine looking characters:
public static string toUTF8(string messageString, string charset)
{
Encoding dstEnc = Encoding.UTF8;
MessageBox.Show (Encoding.Defau lt.ToString());
if(charset.Leng th==0)
{
charset="us-ascii";
}
Encoding srcEnc=Encoding .GetEncoding(ch arset);
byte[] srcData = srcEnc.GetBytes ( messageString );
string utf8String = dstEnc.GetStrin g(srcData);
return utf8String;
}
I hope someone can help me.
Regards,
Albert Jan 1 2017
Albert,
Are you looking for something like this however than with your properiate
code set.
System.Text.Enc oding.GetEncodi ng(437).GetByte s(Str.ReadToEnd )
And than with the proper codeset.
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Oliver Kurz |
last post by:
Hello,
could someone tell me the best way to convert a string to utf, for example
to utf-8?
The problem: I have no controll about the source where the string comes
from. It could have any possible characterset. And I have to convert it for
example to utf-8.
Is there a good way to do this? And when, how?
|
by: hunterb |
last post by:
I have a file which has no BOM and contains mostly single byte chars. There
are numerous double byte chars (Japanese) which appear throughout. I need to
take the resulting Unicode and store it in a DB and display it onscreen. No
matter which way I open the file, convert it to Unicode/leave it as is or
what ever, I see all single bytes ok, but double bytes become 2 seperate
single bytes. Surely there is an easy way to convert these mixed...
|
by: Du Dang |
last post by:
I tried to convert a block of text from iso-8859-1 to utf-8 but all I got
after the convertion is gibberish.
===============================
FileStream fs = File.Open("text.txt", FileMode.Open, FileAccess.Read);
byte b = new byte;
fs.Read(b, 0, length);
b = Encoding.Convert(Encoding.GetEncoding(28591), Encoding.UTF8, b);
|
by: davihigh |
last post by:
My Friends:
I am using std::ofstream (as well as ifstream), I hope that when i
wrote in some std::string(...) with locale, ofstream can convert to
UTF-8 encoding and save file to disk. So does ifstream.
Something I found shows that, I need to have a proper codecvt to set
it. I need more information, maybe a small piece of code sample. Thank
you!
|
by: csanjith |
last post by:
Hi, i have a situaion where i need to convert the characters entered in
an text field to upper case using C. The configuration id utf8
environment in which user can enter any character (single , double,
triple byte etc). I need to convert to upper case only those characters
which has got upper case. ie if an user enter bot english and japanese
characters in the text field, then I should convert only english
characters, not japanese.
| |
by: thinktwice |
last post by:
i'm using VC++6 IDE
i know i could use macros like A2T, T2A,
but is there any way more decent way to do this?
|
by: GM |
last post by:
Dear all,
Could you all give me some guide on how to convert my big5 string to
unicode using python? I already knew that I might use cjkcodecs or
python 2.4 but I still don't have idea on what exactly I should do.
Please give me some sample code if you could. Thanks a lot
Regards,
Gary
|
by: Jared Wiltshire |
last post by:
I'm trying to convert a wstring (actually a BSTR) to UTF-8.
This is what I've currently got:
size_t arraySize;
setlocale(LC_CTYPE,"C-UTF-8");
arraySize = wcstombs(NULL, wstr, 0);
char utf8string;
wcstombs(utf8string, Name, arraySize + 1);
|
by: shapper |
last post by:
Hello,
Could someone tell me how to convert a XML file into another XML file
using a XSL file with a parameter? I created the code to do it, and it
seems ok, but it is not working.
Could somebody, please, help me out? I am on this for days.
My code is as follows:
|
by: Zmische |
last post by:
Platform: IIS6, windows 2000 Server, ASP + VBSCRIPT
I have an ASP application that posts FORM via XMLHttprequest (javascript) so that all data is posted in UTF-8.
So I have an ASP that get data in UTF-8 charset and I should convert it into WINDOWS-1251 charset to send data to DB via ADO.
I tried to use Chilcat Charset ActiveX module, but it didnt work for me because I need to convert from UTF-8 to win1251 into variable, not using...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| | |