# Null character after every character..



## myms (Mar 1, 2010)

i tried to read a file exported by registry editor using c++.
but after every characetr there is a null character
i am not getting this...
can somebody clarify this to me.....

when i open that file using notepad, it is normal...... but when i open with edit there is a null character
does the file occupies more memory due to that null character???

help guys
thanks in advance..
n sory for my english


----------



## Ent (Apr 11, 2009)

The reason for this is that the file was written in Unicode, which has 16 bits per character. Notepad reads it properly, but Edit expects it to be in ASCII which has 8 bits per character. Fortunately the first 256 characters of Unicode are Ascii-equivalent, otherwise you wouldn't be able to read it at all in Edit.

Yes, it will take twice as much space written in Unicode as it would in ASCII.


----------



## myms (Mar 1, 2010)

thanks Ent, that helped a lot.......
is there any way to convert it to normal (8 bit ) character??


----------



## TheOutcaste (Aug 8, 2007)

In Notepad, click *File | Save As...*
Change the *Encoding:* drop down from *Unicode* to *ANSI*.
Give it a new name (Just in case you need the original for something) and click *Save*


----------



## myms (Mar 1, 2010)

that was awesome man....... thnks

and is there a way to change Unicode to Ascii from C++........ i need a read those kinds of file from C++.


----------



## TheOutcaste (Aug 8, 2007)

About all I know about C++ is how to spell it, so don't know if I can be much help on that, but here goes...

The Command Prompt *Type* command will convert from Unicode to ANSI, so if you can call a Command Line Process you can do that.
Just redirect the output from *Type* to a new file, which will be in ANSI format.

```
Type Unicode.reg>ANSI.reg
```
No space in front of the *>*
If you are calling *regedit.exe* to export the key, it should be pretty much the same method to call *Type*. *Type* is an internal command, do you might have to call *cmd.exe* actually:

```
cmd.exe /C "Type Unicode.reg>ANSI.reg"
```
Google found there are both Unicode and ANSI forms of the *RegSaveKey** functions, so you may just need to specify the ANSI version of the function.

From RegSaveKey Function:
*RegSaveKeyW* (Unicode) and *RegSaveKeyA* (ANSI)

From RegSaveKeyEx Function:
*RegSaveKeyExW* (Unicode) and *RegSaveKeyExA* (ANSI)


----------



## myms (Mar 1, 2010)

thank you outcast, you are a genious... ;-)

now using '>' operator i can write any output from dos to a file.......... '>' ROCKS

thanks everyone.


----------



## myms (Mar 1, 2010)

thank you outcast, you are a genious... ;-)

now using '>' operator i can write any output from dos to a file.......... '>' ROCKS

thanks everyone.


----------

