By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,977 Members | 1,617 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,977 IT Pros & Developers. It's quick & easy.

Problems with Converting Sting to Byte Array

P: n/a
I have written a little programm, which converts normal Text into Unicode
Bytes - nothing special, but i tried to creat 2nd Encoder which converts
strings(numbers) in a textBox (strings which i had converted from
UnicodeString to Bytes) to a UnicodeString.
<textbox Text : 0770>
->>> byte[] <--- I want the numbers in the Array
---->>>> as UnicodeString: M

Thx
PS: Please ignore the broken English - It's hard to discribe my problem..
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
byte [] unicodeBytes = new byte[] {77, 0, 79, 0, 77, 0};
string s = System.Text.Encoding.Unicode.GetString(unicodeByte s);

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com

"Max Gattringer" <ma***********@msn.com> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl...
I have written a little programm, which converts normal Text into Unicode
Bytes - nothing special, but i tried to creat 2nd Encoder which converts
strings(numbers) in a textBox (strings which i had converted from
UnicodeString to Bytes) to a UnicodeString.
<textbox Text : 0770>
->>> byte[] <--- I want the numbers in the Array
---->>>> as UnicodeString: M

Thx
PS: Please ignore the broken English - It's hard to discribe my problem..

Nov 16 '05 #2

P: n/a
I need this dynamically -> not just for the number 770 - >

string a = textBox1.Text;

-> i want this string: a(numbers) in the byte Array!
byte [] unicodeBytes = new byte[] {77, 0, 79, 0, 77, 0};
string s = System.Text.Encoding.Unicode.GetString(unicodeByte s);
"Mickey Williams" <my first name at servergeek.com> schrieb im Newsbeitrag
news:eP**************@TK2MSFTNGP09.phx.gbl...
byte [] unicodeBytes = new byte[] {77, 0, 79, 0, 77, 0};
string s = System.Text.Encoding.Unicode.GetString(unicodeByte s);

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com

"Max Gattringer" <ma***********@msn.com> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl...
I have written a little programm, which converts normal Text into Unicode Bytes - nothing special, but i tried to creat 2nd Encoder which converts
strings(numbers) in a textBox (strings which i had converted from
UnicodeString to Bytes) to a UnicodeString.
<textbox Text : 0770>
->>> byte[] <--- I want the numbers in the Array
---->>>> as UnicodeString: M

Thx
PS: Please ignore the broken English - It's hard to discribe my problem..


Nov 16 '05 #3

P: n/a
That was an example. Here's some that can work for you. You need to add your
error handling though.

string[] stringNumbers = this.textBox1.Text.Split(' ');
byte[] unicodeBytes = new byte[stringNumbers.Length];
for (int i = 0; i < stringNumbers.Length; i++) {
unicodeBytes[i] = byte.Parse(stringNumbers[i]);
}

-mike
MVP

"Max Gattringer" <ma***********@msn.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I need this dynamically -> not just for the number 770 - >

string a = textBox1.Text;

-> i want this string: a(numbers) in the byte Array!
byte [] unicodeBytes = new byte[] {77, 0, 79, 0, 77, 0};
string s = System.Text.Encoding.Unicode.GetString(unicodeByte s);


"Mickey Williams" <my first name at servergeek.com> schrieb im Newsbeitrag
news:eP**************@TK2MSFTNGP09.phx.gbl...
byte [] unicodeBytes = new byte[] {77, 0, 79, 0, 77, 0};
string s = System.Text.Encoding.Unicode.GetString(unicodeByte s);

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com

"Max Gattringer" <ma***********@msn.com> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl...
> I have written a little programm, which converts normal Text into Unicode > Bytes - nothing special, but i tried to creat 2nd Encoder which
> converts
> strings(numbers) in a textBox (strings which i had converted from
> UnicodeString to Bytes) to a UnicodeString.
> <textbox Text : 0770>
> ->>> byte[] <--- I want the numbers in the Array
> ---->>>> as UnicodeString: M
>
> Thx
> PS: Please ignore the broken English - It's hard to discribe my problem.. >
>




Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.