[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Character decoding problem

puran

10/2/2003 11:19:00 AM

Hi,

Currently i'm working on developing a component, which
will read all the incoming mails of an smtp server and it
has to decode the actual mail content by using the
encoded content of the mail. I also have the charset used
in encoding the mail.

For eg:
======
If the incoming mail has korean charset as "ks_c_5601-
1987" and encoded string as follows:
----------------------------------------------------------
-------------------------------
³â01¿ù28ÀÏ°æ ¸¶Áö¸·À¸·Î Á¢¼ÓÇÑ°Í °°À½
Á¢¼ÓÇßÀ» °æ¿ì $¼­¹ö¿¡ ¿¬°áÇÏ°í ÀÖÀ½$À̶ó°í

The actual message is as follows:
---------------------------------
أ년01월28일경 마지막으로 접속한것 같음
접속했을 경우 $서버에 연결하고 있음$이라고

I've tried to decode the encoded content to get the
korean text using following code:

string rfc1522EncodedString = "³â01¿ù28ÀÏ°
æ ¸¶Áö¸·À¸·Î Á¢¼ÓÇÑ°Í °°À½Á¢¼ÓÇßÀ» °æ¿ì $¼­¹ö¿¡ ¿¬°áÇÏ°í
ÀÖÀ½$À̶ó°í";

Encoding rfc1522Encoding =
Encoding.GetEncoding("iso-8859-1");
Encoding koreanEncoding =
Encoding.GetEncoding("ks_c_5601-1987");

byte[] rfc1522EncodingBytes =
rfc1522Encoding.GetBytes(rfc1522EncodedString);
byte[] koreanEncodingBytes =
Encoding.Convert(rfc1522Encoding, koreanEncoding,
rfc1522EncodingBytes);
string decodedString =
koreanEncoding.GetString(koreanEncodingBytes);



Can anyone give me few pointers in fixing this.

Thanks in advance
Puri

1 Answer

Dmitriy Lapshin

10/3/2003 7:52:00 AM

0

Hi,

You should first apply HtmlDecode to the message contents if it is in a form
of &#nnnn;&#mmmm;...

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/tests...
Bring the power of unit testing to VS .NET IDE

"puran" <pguggi@msn.com> wrote in message
news:1b2401c388d6$f54dee90$a301280a@phx.gbl...
Hi,

Currently i'm working on developing a component, which
will read all the incoming mails of an smtp server and it
has to decode the actual mail content by using the
encoded content of the mail. I also have the charset used
in encoding the mail.

For eg:
======
If the incoming mail has korean charset as "ks_c_5601-
1987" and encoded string as follows:
----------------------------------------------------------
-------------------------------
??01??28??°? ?¶???·??·? ??????°? °°??
???????» °??? $?­???? ?¬°???°? ????$??¶?°?

The actual message is as follows:
---------------------------------
&#1571;&#45380;01&#50900;28&#51068;&#44221;
&#47560;&#51648;&#47561;&#51004;&#47196; &#51217;&#49549;&#54620;&#44163;
&#44057;&#51020;
&#51217;&#49549;&#54664;&#51012; &#44221;&#50864; $&#49436;&#48260;&#50640;
&#50672;&#44208;&#54616;&#44256; &#51080;&#51020;$&#51060;&#46972;&#44256;

I've tried to decode the encoded content to get the
korean text using following code:

string rfc1522EncodedString = "??01??28??°
? ?¶???·??·? ??????°? °°?????????» °??? $?­???? ?¬°???°?
????$??¶?°?";

Encoding rfc1522Encoding =
Encoding.GetEncoding("iso-8859-1");
Encoding koreanEncoding =
Encoding.GetEncoding("ks_c_5601-1987");

byte[] rfc1522EncodingBytes =
rfc1522Encoding.GetBytes(rfc1522EncodedString);
byte[] koreanEncodingBytes =
Encoding.Convert(rfc1522Encoding, koreanEncoding,
rfc1522EncodingBytes);
string decodedString =
koreanEncoding.GetString(koreanEncodingBytes);



Can anyone give me few pointers in fixing this.

Thanks in advance
Puri