|
-
Mar 19th, 2003, 12:56 PM
#1
Thread Starter
New Member
string to byte array "åäöÿ" is "????"
Hi
I have a question about byte arrays.
This is the line where it be wrong.
CODE]
Dim MyByte() As Byte = Encoding.ASCII.GetBytes(sString)
[/CODE]
if I have a ÿ in "sString" then it change it to ? it´s the same with åäö.
Do anybody now how to fix it!
plz
Tankz m00gly
Why search and search when you can ask.
-
Mar 19th, 2003, 07:31 PM
#2
Hyperactive Member
Re: string to byte array "åäöÿ" is "????"
Originally posted by m00gly
Hi
I have a question about byte arrays.
This is the line where it be wrong.
CODE]
Dim MyByte() As Byte = Encoding.ASCII.GetBytes(sString)
[/CODE]
if I have a ÿ in "sString" then it change it to ? it´s the same with åäö.
Do anybody now how to fix it!
plz
Tankz m00gly
Hmm, I remember having this problem as well! I think it has something to do with the fact that Strings in .NET use the unicode character set (each character is two bytes, not one).
I'll go find a work around!
-
Mar 19th, 2003, 08:24 PM
#3
PowerPoster
Yep, .NET utilizes the unicode character set. You can use the UnicodeEncoding class for all unicode manipulation:
Code:
byte[] bytes = new System.Text.UnicodeEncoding().GetBytes(value);
-
Mar 20th, 2003, 11:36 AM
#4
Thread Starter
New Member
thanks but i´ve didn´t get it to work
Hmm it didn´t work for me, my function looks like this
Code:
Public Function SendText(ByVal sValue As String, ByVal sRemoteHost As String)
Dim MyByte As Byte()
MyByte = New System.Text.UnicodeEncoding().GetBytes(sValue)
MySocket.Send(MyByte, MyByte.Length, sRemoteHost)
End Function
With this code "ÿ" will be a "square" and "å" will be "e"
Why search and search when you can ask.
-
Mar 20th, 2003, 03:41 PM
#5
Thread Starter
New Member
Sorry my mistake?
I hav forgot to change to unicode in the recive function!
Tanks for all help
Why search and search when you can ask.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|