Re: I cannot reliably write the Hex number "83" to a stream
- From: "Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx>
- Date: Wed, 16 Jan 2008 09:18:45 -0600
"ajmastrean" <ajmastrean@xxxxxxxxx> wrote in message
news:6762e194-cd29-46b5-a222-c496782ba26f@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I cannot get any (hex) number in the "0x80"-"0x89" range (inclusive)
to write properly to a file. Any number in this range magically
transforms itself into "0x3F". For instance, debugging shows that
"0x83" = UInt16 "131" and that converts to Char (curly) "f". Any
information would be helpful.
String[] hexNum = { "79", "80", "89", "90" };
System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(@"C:
\test.dbf", true, System.Text.Encoding.Default);
The only thing the "default" encoding is good for is sending to another .NET
program that also uses the default encoding. You're giving it permission to
store the data in the file any way it chooses.
If you need a particular encoding, then set the encoding to what you need.
Or use byte instead of char, bytes do not undergo encoding transformations.
foreach (String hex in hexNum)
{
Char hexChar = (Char)UInt16.Parse(hex,
System.Globalization.NumberStyles.HexNumber);
streamWriter.Write(hexChar);
}
streamWriter.Flush();
streamWriter.Close();
.
- References:
- I cannot reliably write the Hex number "83" to a stream
- From: ajmastrean
- I cannot reliably write the Hex number "83" to a stream
- Prev by Date: Re: null is unrecognized literal
- Next by Date: Re: IP address for a socket service
- Previous by thread: Re: I cannot reliably write the Hex number "83" to a stream
- Next by thread: Re: I cannot reliably write the Hex number "83" to a stream
- Index(es):
Relevant Pages
|