PC Review


Reply
Thread Tools Rate Thread

problem with encoding

 
 
Vaidas Gudas
Guest
Posts: n/a
 
      4th Apr 2006
Code:

Dim enc As New System.Text.ASCIIEncoding

Dim serverbuff(1024), buff(0) As Byte

Dim count, bytes As Integer

Dim stream As NetworkStream

stream = o.GetStream()

While 1 = 1

bytes = stream.Read(buff, 0, 1)

If bytes = 1 Then

serverbuff(count) = buff(0)

count = count + 1

If buff(0) = Asc(vbLf) Then

Exit While

End If

Else

Exit While

End If

End While

Return enc.GetString(serverbuff, 0, count)

I am using POP 3 protocol and I am rading the data from exchange server.
I am geting the data from POP3 in string format, but some character, witch
it is not Latin characters is enncoded, and I need to decode to Lithuanian
character set. How to make this.






 
Reply With Quote
 
 
 
 
Joerg Jooss
Guest
Posts: n/a
 
      4th Apr 2006
Thus wrote Vaidas,

> Code:
>
> Dim enc As New System.Text.ASCIIEncoding

[...]
> I am using POP 3 protocol and I am rading the data from exchange
> server.
> I am geting the data from POP3 in string format, but some character,
> witch
> it is not Latin characters is enncoded, and I need to decode to
> Lithuanian
> character set. How to make this.


Don't use US-ASCII. That's 7 bit only and no good for most European languages.
You should be using the encoding specified by mail's headers.

Cheers,
--
Joerg Jooss
news-(E-Mail Removed)


 
Reply With Quote
 
Vaidas Gudas
Guest
Posts: n/a
 
      5th Apr 2006
How to make encoding like this

Content-Type: text/plain;

charset="iso-8859-2"



"Joerg Jooss" <news-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thus wrote Vaidas,
>
>> Code:
>>
>> Dim enc As New System.Text.ASCIIEncoding

> [...]
>> I am using POP 3 protocol and I am rading the data from exchange
>> server.
>> I am geting the data from POP3 in string format, but some character,
>> witch
>> it is not Latin characters is enncoded, and I need to decode to
>> Lithuanian
>> character set. How to make this.

>
> Don't use US-ASCII. That's 7 bit only and no good for most European
> languages. You should be using the encoding specified by mail's headers.
> Cheers,
> --
> Joerg Jooss
> news-(E-Mail Removed)
>
>



 
Reply With Quote
 
Joerg Jooss
Guest
Posts: n/a
 
      5th Apr 2006
Thus wrote Vaidas,

> How to make encoding like this
>
> Content-Type: text/plain;
>
> charset="iso-8859-2"


Use System.Text.Encoding.GetEncoding() to create an Encoding instance by
its IANA name, e.g.

Encoding latin2 = Encoding.GetEncoding("iso-8859-2");

Cheers,
--
Joerg Jooss
news-(E-Mail Removed)


 
Reply With Quote
 
Vaidas Gudas
Guest
Posts: n/a
 
      5th Apr 2006
It dont work

"Joerg Jooss" <news-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thus wrote Vaidas,
>
>> How to make encoding like this
>>
>> Content-Type: text/plain;
>>
>> charset="iso-8859-2"

>
> Use System.Text.Encoding.GetEncoding() to create an Encoding instance by
> its IANA name, e.g.
>
> Encoding latin2 = Encoding.GetEncoding("iso-8859-2");
>
> Cheers, --
> Joerg Jooss
> news-(E-Mail Removed)
>
>



 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      6th Apr 2006
Vaidas Gudas <(E-Mail Removed)> wrote:
> It dont work


Well, that line of code definitely *does* work. If something else
doesn't work, you need to give us more information.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how does ado.net SqlDataReader.GetString() know which encoding to read the data into a string as? Does sql sever set this at the column data type level, server wide encoding setting, os encoding? Daniel Microsoft C# .NET 1 25th Mar 2007 06:47 PM
how does ado.net SqlDataReader.GetString() know which encoding to read the data into a string as? Does sql sever set this at the column data type level, server wide encoding setting, os encoding? Daniel Microsoft Dot NET Framework 1 8th Mar 2007 12:06 PM
how does ado.net SqlDataReader.GetString() know which encoding to read the data into a string as? Does sql sever set this at the column data type level, server wide encoding setting, os encoding? Daniel Microsoft ADO .NET 0 8th Mar 2007 12:15 AM
how does ado.net SqlDataReader.GetString() know which encoding to read the data into a string as? Does sql sever set this at the column data type level, server wide encoding setting, os encoding? Daniel Microsoft Dot NET 0 8th Mar 2007 12:12 AM
Different encoding? ( problem on Chinese encoding on textbox ... ) Boki Microsoft VB .NET 1 28th Apr 2006 11:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:36 PM.