Re: I cannot reliably write the Hex number "83" to a stream
- From: Lasse Vågsæther Karlsen <lasse@xxxxxxxxxxx>
- Date: Wed, 16 Jan 2008 16:06:14 +0100
ajmastrean wrote:
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);
foreach (String hex in hexNum)
{
Char hexChar = (Char)UInt16.Parse(hex,
System.Globalization.NumberStyles.HexNumber);
streamWriter.Write(hexChar);
}
streamWriter.Flush();
streamWriter.Close();
Have you looked at the default encoding and what it does to your data?
Since you're writing text characters through an encoding object, it will in some cases encode the characters different than if you just output pure bytes to begin with.
--
Lasse Vågsæther Karlsen
mailto:lasse@xxxxxxxxxxx
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
.
- 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: null is unrecognized literal
- Previous by thread: 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
|