-
April 18th, 2005, 07:45 AM
#1
string to byte[]
how do I do string to byte[]?
there is
Encoding.ASCII.GetBytes
Convert.FromBase64String
BitConverter
Encoding.UTF8
UnicodeEncoding
etc
I don't understand all the diff.
AFAIK the input will be not limited to ascii. It will have eg Japanese input from a J WinXP.
Also, what is the big/little endian deal? I thought .net frame should deal with those details??
-
April 18th, 2005, 07:58 AM
#2
Re: string to byte[]
you can use... the one...
Encoding.default.getbytes() function.
If you think you CAN, you can, If you think you CAN'T, you are probably right.
Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.
-
April 18th, 2005, 08:02 AM
#3
Re: string to byte[]
how about dealing with Japanese input from a J WinXP.
then reading the same on Eng WinXP?
This endian thing is also worrying, one day someone's going to run .net on some wierd processor and everything will explode??!
-
April 18th, 2005, 08:55 AM
#4
Re: string to byte[]
If you're doing the conversion using Unicode then you'll be fine.
However if you're doing it to ASCII you'll have to set up the codepage :
Code:
string sString = "<some japanese>";
// get the encoding specifying a code page.
Encoding asciiJapanese = System.Text.ASCIIEncoding.GetEncoding(932);
byte [] abData = ascciiJapanese.GetBytes(sString);
932 is the code page for Japanese.
Darwen.
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
|