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(inputt ext.ToString)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
Since there is no char value for hex 00 (NUL) it's not possible to use a
string as input..
Thanks,
Sven 10 3938
"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(inputt ext.ToString) networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
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.Defaul t.GetBytes(inpu ttext.ToString)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
Encoding.Defaul t 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(inputt ext.ToString) networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
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.Defaul t.GetBytes(inpu ttext.ToString)
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
Encoding.Defaul t 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.N ullChar' 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.N ullChar' 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_code s_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*******@free net.de> wrote in message
news:ud******** *****@TK2MSFTNG P11.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(inputt ext.ToString) networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
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.Defaul t.GetBytes(inpu ttext.ToString) networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
Encoding.Defaul t 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_code s_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*******@free net.de> wrote in message
news:ud******** *****@TK2MSFTNG P11.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(inputt ext.ToString) networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
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.Defaul t.GetBytes(inpu ttext.ToString) networkStream.W rite(sendBytes, 0, sendBytes.Lengt h)
Encoding.Defaul t 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_code s_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.Ge tBytes(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_code s_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.Ge tBytes(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_code s_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.Ge tBytes(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 transactional data files to mysql and I'm stumped trying
to convert the currency data bytes.
For example: I'm looking for a php function to convert (40 3E 51 EB 85 1E
B8 52) hex to ($30.32) foating (double precision 64 bits)
I'm not sure if this...
|
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 the format. The
format states that the general packet format is as follows
Message header
Hex Length of whole binary packet
|
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 value that lowercase hex
digits are ugly, should we care?
|
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 << "'" << std::endl;
VC++ 7.1 says:
| |
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 used until reset". For some reason, I interpreted this to
mean that "<< hex" manipulator would cause the base to be set for only
the current statement, while the cout.setf(ios_base::hex) statement
would cause the base to be set for multiple...
|
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 I'm looking at '0' - '9', 'A' - 'Z'
and 'a' - 'z'.
Here is what I've got:
int num = 0;
|
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 can't really u'stand how to do it!
can anyone explain me wat should i do to in order to create a program for this company.
1)should i use array or structure for this program?
2)how to convert it into a hex file?
thank you for your help and...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |