Hello,
I need to send a couple of "NUL"s -> HEX value "00" on a networkstream..
This is the code we currently use to send string:
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(inputtext.ToString)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Since there is no char value for hex 00 (NUL) it's not possible to use a
string as input..
Thanks,
Sven 10 3908
"Sven Huijbrechts" <sv**@no-spam-hts.be> schrieb I need to send a couple of "NUL"s -> HEX value "00" on a networkstream..
This is the code we currently use to send string: Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(inputtext.ToString) networkStream.Write(sendBytes, 0, sendBytes.Length)
Since there is no char value for hex 00 (NUL) it's not possible to use a string as input..
Why is there no "char value"? chr(0) returns such a char. Don't use ASCII
encoding because ASCII = 7 bits. Do you want to send the character codes of
the hexadecimal string representation of the chars, or do you want to send
the character codes themselves? What is "inputtext"? What does it contain
for example?
One possible solution:
Dim sendBytes As Byte() 'no [ ] required here
sendBytes = Encoding.Default.GetBytes(inputtext.ToString)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Encoding.Default returns the current ANSI codepage (8-Bit character codes).
The other solution depends on the answers to the questions above.
Maybe you can use a Streamwriter instead. You could pass the encoding once
to the constructor and don't have to convert each string on your own.
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
"Sven Huijbrechts" <sv**@no-spam-hts.be> schrieb I need to send a couple of "NUL"s -> HEX value "00" on a networkstream..
This is the code we currently use to send string: Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(inputtext.ToString) networkStream.Write(sendBytes, 0, sendBytes.Length)
Since there is no char value for hex 00 (NUL) it's not possible to use a string as input..
Why is there no "char value"? chr(0) returns such a char. Don't use ASCII
encoding because ASCII = 7 bits. Do you want to send the character codes of
the hexadecimal string representation of the chars, or do you want to send
the character codes themselves? What is "inputtext"? What does it contain
for example?
One possible solution:
Dim sendBytes As Byte() 'no [ ] required here
sendBytes = Encoding.Default.GetBytes(inputtext.ToString)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Encoding.Default returns the current ANSI codepage (8-Bit character codes).
The other solution depends on the answers to the questions above.
Maybe you can use a Streamwriter instead. You could pass the encoding once
to the constructor and don't have to convert each string on your own.
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
* "Sven Huijbrechts" <sv**@no-spam-hts.be> scripsit: Since there is no char value for hex 00 (NUL) it's not possible to use a string as input..
?!?
You can use 'ControlChars.NullChar' to get a null character.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
* "Sven Huijbrechts" <sv**@no-spam-hts.be> scripsit: Since there is no char value for hex 00 (NUL) it's not possible to use a string as input..
?!?
You can use 'ControlChars.NullChar' to get a null character.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
When you look at this page:
ms-help://MS.VSCC/MS.MSDNVS/vsintro7/html/_pluslang_ascii_character_codes_ch
art_1.htm
The first line (Dec: 0 / Hex: 00 / Char: / Code: NUL) is the code I have to
send..
I need to send a bigendian HEX value over the networkstream.
So I want to fill the array sendBytes with '00','00','00','3E' for example.
My problem is that the string '0000003E' is converted to hex
'30','30','30','30','30','30','33','45'
And there is no string which translates to hex '00','00','00','3E'
Sven
"Armin Zingler" <az*******@freenet.de> wrote in message
news:ud*************@TK2MSFTNGP11.phx.gbl... "Sven Huijbrechts" <sv**@no-spam-hts.be> schrieb I need to send a couple of "NUL"s -> HEX value "00" on a networkstream..
This is the code we currently use to send string: Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(inputtext.ToString) networkStream.Write(sendBytes, 0, sendBytes.Length)
Since there is no char value for hex 00 (NUL) it's not possible to use a string as input.. Why is there no "char value"? chr(0) returns such a char. Don't use ASCII encoding because ASCII = 7 bits. Do you want to send the character codes
of the hexadecimal string representation of the chars, or do you want to send the character codes themselves? What is "inputtext"? What does it contain for example?
One possible solution: Dim sendBytes As Byte() 'no [ ] required here sendBytes = Encoding.Default.GetBytes(inputtext.ToString) networkStream.Write(sendBytes, 0, sendBytes.Length)
Encoding.Default returns the current ANSI codepage (8-Bit character
codes). The other solution depends on the answers to the questions above.
Maybe you can use a Streamwriter instead. You could pass the encoding once to the constructor and don't have to convert each string on your own.
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
When you look at this page:
ms-help://MS.VSCC/MS.MSDNVS/vsintro7/html/_pluslang_ascii_character_codes_ch
art_1.htm
The first line (Dec: 0 / Hex: 00 / Char: / Code: NUL) is the code I have to
send..
I need to send a bigendian HEX value over the networkstream.
So I want to fill the array sendBytes with '00','00','00','3E' for example.
My problem is that the string '0000003E' is converted to hex
'30','30','30','30','30','30','33','45'
And there is no string which translates to hex '00','00','00','3E'
Sven
"Armin Zingler" <az*******@freenet.de> wrote in message
news:ud*************@TK2MSFTNGP11.phx.gbl... "Sven Huijbrechts" <sv**@no-spam-hts.be> schrieb I need to send a couple of "NUL"s -> HEX value "00" on a networkstream..
This is the code we currently use to send string: Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(inputtext.ToString) networkStream.Write(sendBytes, 0, sendBytes.Length)
Since there is no char value for hex 00 (NUL) it's not possible to use a string as input.. Why is there no "char value"? chr(0) returns such a char. Don't use ASCII encoding because ASCII = 7 bits. Do you want to send the character codes
of the hexadecimal string representation of the chars, or do you want to send the character codes themselves? What is "inputtext"? What does it contain for example?
One possible solution: Dim sendBytes As Byte() 'no [ ] required here sendBytes = Encoding.Default.GetBytes(inputtext.ToString) networkStream.Write(sendBytes, 0, sendBytes.Length)
Encoding.Default returns the current ANSI codepage (8-Bit character
codes). The other solution depends on the answers to the questions above.
Maybe you can use a Streamwriter instead. You could pass the encoding once to the constructor and don't have to convert each string on your own.
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
"Sven Huijbrechts" <sv**@no-spam-hts.be> schrieb When you look at this page:
ms-help://MS.VSCC/MS.MSDNVS/vsintro7/html/_pluslang_ascii_character_codes_ch art_1.htm
The first line (Dec: 0 / Hex: 00 / Char: / Code: NUL) is the code I have to send.. I need to send a bigendian HEX value over the networkstream. So I want to fill the array sendBytes with '00','00','00','3E' for example.
My problem is that the string '0000003E' is converted to hex '30','30','30','30','30','30','33','45' And there is no string which translates to hex '00','00','00','3E'
You say the string to be sent is "0000003E"? If yes:
Dim s As String = "0000003E"
Dim b As Byte()
Dim i As Integer
ReDim b(s.Length \ 2 - 1)
For i = 0 To s.Length Step 2
b(i \ 2) = Convert.ToByte(s.Substring(i, 2), 16)
Next
If it is always 8 chars in the source string (representing an Integer):
b = BitConverter.GetBytes(Convert.ToInt32(s, 16)).
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
"Sven Huijbrechts" <sv**@no-spam-hts.be> schrieb When you look at this page:
ms-help://MS.VSCC/MS.MSDNVS/vsintro7/html/_pluslang_ascii_character_codes_ch art_1.htm
The first line (Dec: 0 / Hex: 00 / Char: / Code: NUL) is the code I have to send.. I need to send a bigendian HEX value over the networkstream. So I want to fill the array sendBytes with '00','00','00','3E' for example.
My problem is that the string '0000003E' is converted to hex '30','30','30','30','30','30','33','45' And there is no string which translates to hex '00','00','00','3E'
You say the string to be sent is "0000003E"? If yes:
Dim s As String = "0000003E"
Dim b As Byte()
Dim i As Integer
ReDim b(s.Length \ 2 - 1)
For i = 0 To s.Length Step 2
b(i \ 2) = Convert.ToByte(s.Substring(i, 2), 16)
Next
If it is always 8 chars in the source string (representing an Integer):
b = BitConverter.GetBytes(Convert.ToInt32(s, 16)).
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
"Sven Huijbrechts" <sv**@no-spam-hts.be> schrieb When you look at this page:
ms-help://MS.VSCC/MS.MSDNVS/vsintro7/html/_pluslang_ascii_character_codes_ch art_1.htm
The first line (Dec: 0 / Hex: 00 / Char: / Code: NUL) is the code I have to send.. I need to send a bigendian HEX value over the networkstream. So I want to fill the array sendBytes with '00','00','00','3E' for example.
My problem is that the string '0000003E' is converted to hex '30','30','30','30','30','30','33','45' And there is no string which translates to hex '00','00','00','3E'
You say the string to be sent is "0000003E"? If yes:
Dim s As String = "0000003E"
Dim b As Byte()
Dim i As Integer
ReDim b(s.Length \ 2 - 1)
For i = 0 To s.Length Step 2
b(i \ 2) = Convert.ToByte(s.Substring(i, 2), 16)
Next
If it is always 8 chars in the source string (representing an Integer):
b = BitConverter.GetBytes(Convert.ToInt32(s, 16)).
......
I forgot: In the first example the byte order must be reversed.
To reverse an existing array, use Array.Reverse.
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
thanks for the info..
I'll have a look at it soon, currently other priorities..
Greetings,
Sven
"Armin Zingler" <az*******@freenet.de> wrote in message
news:ug*************@TK2MSFTNGP11.phx.gbl... "Sven Huijbrechts" <sv**@no-spam-hts.be> schrieb When you look at this page:
ms-help://MS.VSCC/MS.MSDNVS/vsintro7/html/_pluslang_ascii_character_codes_ch art_1.htm
The first line (Dec: 0 / Hex: 00 / Char: / Code: NUL) is the code I have to send.. I need to send a bigendian HEX value over the networkstream. So I want to fill the array sendBytes with '00','00','00','3E' for example.
My problem is that the string '0000003E' is converted to hex '30','30','30','30','30','30','33','45' And there is no string which translates to hex '00','00','00','3E'
You say the string to be sent is "0000003E"? If yes:
Dim s As String = "0000003E" Dim b As Byte() Dim i As Integer
ReDim b(s.Length \ 2 - 1)
For i = 0 To s.Length Step 2 b(i \ 2) = Convert.ToByte(s.Substring(i, 2), 16) Next
If it is always 8 chars in the source string (representing an Integer):
b = BitConverter.GetBytes(Convert.ToInt32(s, 16)).
.....
I forgot: In the first example the byte order must be reversed. To reverse an existing array, use Array.Reverse.
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: DvGrimm |
last post by:
Any help would be very, very much appreciated...
I've been searching the net (google) for 4 days now trying to find a php
function to convert hex to floating point.
I'm converting old...
|
by: Paul |
last post by:
Hi,
(First apologies if this is not the most relevant place to post this
but I wasn't sure of where was and I am writing my app in VB.)
I'm attempting to parse a binary file for which I have...
|
by: Delali Dzirasa |
last post by:
I would have a number packed with its hex representation of the integer
below is some sample code of what is being done.
int value = 20; //in hex it is 0x14
AddData (value);
..
..
..
|
by: Steven D'Aprano |
last post by:
hex() of an int appears to return lowercase hex digits, and hex() of a
long uppercase.
>>> hex(75)
'0x4b'
>>> hex(75*256**4)
'0x4B00000000L'
By accident or design? Apart from the aesthetic...
|
by: Luther Baker |
last post by:
Hi,
This doesn't do what I expect.
int t = 27;
std::cout << "myHex: '" << std::ios::hex << t << "'" << std::endl;
std::cout.setf(std::ios::hex);
std::cout << "moreHex: '" << t << "'" <<...
|
by: Generic Usenet Account |
last post by:
What exactly is the difference between the hex manipulator and the
following statement: cout.setf(ios_base::hex)?
According to Stroustrup, Third Edition, Section 21.4.4, "once set, a
base is...
|
by: kuukelekuu |
last post by:
I need to convert ascii chars to hex chars.
I searched the internet, found hex to ascii, but nowhere is there a
ascii to hex method created by anyone.
Can anyone help me with that?
Chears
|
by: James Brown |
last post by:
All,
I have a series of characters which I need to convert to integer values.
Each character is read in turn from a function 'nextch', and hex-digits are
identified by the isxdigit function - so...
|
by: twang090 |
last post by:
Trying to create a 12 digit "guid", but have no idea on how to, anyone
please have any thought? Thanks in advance.
|
by: kelly86 |
last post by:
hi guys im stuck here...actually i was asked 2 use C language to create a hex reader/compiler/editor, for use in test department for modifying *.bin files.
Well as a new trainee in this company i...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |