Hi,
Everything is in the title I have an array in Byte[] which contains the ASCII code of a string but I have to give to my function a Byte[] that have Hex values of my string and not ASCII. How can I do that?
I have actually this code:
String abcd = "You got 1 voicemail";
Byte[] test = System.Text.ASCIIEncoding.UTF8.GetBytes(abcd);
I'm developping in C#.NET
Loading
sudheer panwarPosted Jan 30, 2006, 5:02 AM
private
byte[] ConvertToHexArray(byte [] asciiData){ if(asciiData != null && asciiData.Length >0){ byte[] byteHexArray = new byte[asciiData.Length]; for(int i = 0; ibyteHexArray[i]= Byte.Parse(asciiData[i].ToString("X2"),NumberStyles.HexNumber);
}
return null;}
AnttiPosted Jan 27, 2006, 11:15 AM
What do you mean you have "characters in ascii bytes" and "characters in hex"? If you convert your ASCII's to bytes, they are numbers. So it doesent matter if you read them as decimal numbers or hex numbers.
akaii de ShangaiiPosted Jan 27, 2006, 9:23 AM
So if you know how I can do this it would help me a lot.
akaii de ShangaiiPosted Jan 27, 2006, 8:10 AM
when it arrives at line:
byteHexArray[i] = Byte.Parse(asciiData[i].ToString("X2"));
This is the string I need to convert: "You got 1 voicemail"
sudheer panwarPosted Jan 27, 2006, 7:14 AM
Hi,
try this , plz tell me if it fits ur req.
private byte[] ConvertToHexArray(byte [] asciiData)
{
if(asciiData != null && asciiData.Length >0)
{
byte[] byteHexArray = new byte[asciiData.Length];
for(int i = 0; i
return byteHexArray;
byteHexArray[i]= Byte.Parse(asciiData[i].ToString("X2"));
}
return null;
}
sudheer panwarPosted Jan 27, 2006, 7:14 AM
Hi,
try this , plz tell me if it fits ur req.
private byte[] ConvertToHexArray(byte [] asciiData)
{
if(asciiData != null && asciiData.Length >0)
{
byte[] byteHexArray = new byte[asciiData.Length];
for(int i = 0; i
return byteHexArray;
byteHexArray[i]= Byte.Parse(asciiData[i].ToString("X2"));
}
return null;
}
SimonPosted Jan 27, 2006, 6:30 AM
Simon