Rene,
sorry i guess this would work if i did create a ".bin" file.
the output file is a "text" file. the program reads a given registry hive
and enumerates it.
the program emulates the "regedit" export but it will read local and remote
machine.
the program creates an output file in "text" format then in "reg" format.
the later can be imported via regedit.
it also validates a specific hive to see if there are missing keys, missing
values and corrupts as it did in this case.
i guess i realizing there are too many issues to over come unless i'm wrong.
1) in this test run on the a machine i found a key with the wrong codepage
being used.
2) i don't think i can change the codepage output in run-time. meaning if i
create the output file in "reg" mode i'm using default ASCII.
and the format of the file can not be changed to something else for a given
line.
3) i need to alter my plan to exclude the corrupted key and create an
error.txt file with exceptions.
if i'm wrong i look forward to input.
i would like to thank all you who volunteer your input. well done.
"Rene" wrote:
static void Main(string[] args)
{
// Your none ASCII character.
char charFromRegistry = (char)0xE0;
// Save the char to a file.
using (FileStream fs = new FileStream(@"C:\Err.bin", FileMode.Create))
{
byte[] uniBytes = Encoding.Unicode.GetBytes(new char[] {
charFromRegistry });
fs.WriteByte(uniBytes[0]);
}
// Read the char from the file.
using (FileStream fs = new FileStream(@"C:\Err.bin", FileMode.Open))
{
byte b = (byte)fs.ReadByte();
}
}
Perhaps I am missing something????
"auldh" <au***@discussions.microsoft.comwrote in message
news:50**********************************@microsof t.com...
it sounds right. but from the registry key it looks like an "a" with a "`"
over it and it comes closer to codepage 1250.
i just can't figue out how to copy extactly to a new output file.
if i could just find a way to write via "streamwriter.write" this one
character set via a different codepage.
"qg**********@mailinator.com" wrote:
Looks like you are reading the Unicode UTF16 character “00E0” 'LATIN
SMALL LETTER A WITH GRAVE'
http://www.fileformat.info/info/unic...00e0/index.htm
and then you are writing the character to a file using the default
encoding of UTF8 which will end up translating the UTF16 byte from
“00E0” to UTF8 “C3A0”.
If you want to have an exact copy of the bytes you are reading, then
you will need to set your StreamWritter encoding to UTF16 (.Net calls
it Encoding.Unicode) that way, if you open the file in binary mode you
will see “00E0” and not “C3A0”.
At least I think that is what’s going on…..
Rene
On Jun 9, 9:41 am, auldh <au...@discussions.microsoft.comwrote:
i have come across a situation in my project where i read a text file
with
some characters greater than hex 0x7f.
i need to write character (0xE0) to a new file as an exception. however
when
i attempt to write this via "Console.Write" or "filestream.Write" it
seems
the value changes. most of the output file is in text mode.
if i view the original file in binary mode i see the character i'm
having
issue with as "e0 00" but when i re-write it i get "C3 A0".
i just can not reproduce the read information in my output file. is
there
way to do this and if so how?