473,386 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Convert Hex-value in chraracter and after that in Byte

Hello All,

I try to convert hex-value "&HAA" in character and after that in byte

Dim sTest As String
Dim Encoder As New System.Text.ASCIIEncoding
Dim bByte() As Byte

sTest = Chr(&HAA)
bByte = Encoder.GetBytes(sTest)

As result I have "bByte = 63", but "63" is code for character "?".
Can enybody explain me this phenomenon???
Thanks in advance.

Alexander.

Nov 21 '05 #1
3 1435
Alexander,

Not to difficult. ASCII is 7 bit code what is until 127
AA = 170

I hope this helps

Cor
Nov 21 '05 #2
Try this.

Dim sTest As String
Dim Encoder As New System.Text.UnicodeEncoding
Dim bByte() As Byte

sTest = Chr(&HAA)
bByte = Encoder.GetBytes(sTest)

Chris

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Oo**************@TK2MSFTNGP12.phx.gbl...
Alexander,

Not to difficult. ASCII is 7 bit code what is until 127
AA = 170

I hope this helps

Cor

Nov 21 '05 #3
"Alexander Levchenko" <Al****************@discussions.microsoft.com>
schrieb:
I try to convert hex-value "&HAA" in character and after that in byte

Dim sTest As String
Dim Encoder As New System.Text.ASCIIEncoding
Dim bByte() As Byte

sTest = Chr(&HAA)
ASCII is always 7-bit, so there are only characters with codes 0 through
127. '&HAA' = 170, so it's not an ASCII character.
bByte = Encoder.GetBytes(sTest)


If you want to use the current Windows ANSI codepage:

\\\
bByte = System.Text.Encoding.Default.GetBytes(sTest)
///

This will return a byte array with one element containing 170.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Eric | last post by:
Guys, I have the following hexadecimal string - '\xff\xff\xff' which i need to convert to binary. How would i go about doing this? Eric
4
by: Trond Hoiberg | last post by:
I was wondering if someone in here knows if it is possible to convert a letter (a, b, c....) to the ISO Latin-1 Character Set Decimal code? a= a b=b c=c I know it is possible but i was looking...
6
by: MrKrich | last post by:
I want to convert Hexadecimal or normal integer to Binary. Does VB.Net has function to do that? I only found Hex function that convert normal integer to Hexadecimal.
5
by: Mika M | last post by:
Hi! I've made little code to convert string into hex string... Public ReadOnly Property ToHexString(ByVal text As String) As String Get Dim arrBytes As Integer() = CharsToBytes(text) Dim sb...
28
by: MLH | last post by:
The largest integer A97 can deal with is 2,147,483,647, as I understand it from HELP. I would be content to represent larger integers as strings. For example, "2147483648" would suit me fine. I...
4
by: mcmreddy | last post by:
Hi! Is there a way to convert application id ( db2 list applications output) to a readable format?. Auth Id Application Appl. Application Id DB # of Name ...
9
by: Chen Shu | last post by:
Hi there: These days I came to a problem that I failed to convert a binary number to a hex number using a macro. For example: int a = BINARY4(0101) will become int a = 0x5; int a =...
9
by: =?Utf-8?B?Qnlyb24=?= | last post by:
How do you convert a hex string into a double using C# in framework v2.0? I've seen this question answered before, but apparently something has changed in 2.0 that negates the old solution that...
15
by: Lyosha | last post by:
Converting binary to base 10 is easy: 255 Converting base 10 number to hex or octal is easy: '0144' '0x64' Is there an *easy* way to convert a number to binary?
5
by: Angus | last post by:
Hello I have an unsigned char and I want to convert the individual array values into hex and copy to a std::string. The array does not always hold 14 values - but I do know the length of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.