Re: unicode file
- From: "Mihai N." <nmihai_year_2000@xxxxxxxxx>
- Date: Sun, 22 Jun 2008 11:42:09 -0700
how can now if the file is unicode or ansi
and if is ansi how can i convert it to unicode
Adding even more to the answers from Tom and Giovanni :-)
If you use a VS8, take a loot at _open:
http://msdn.microsoft.com/en-us/library/z0kc8e3z(VS.80).aspx
You can specify _O_TEXT, _O_U16TEXT, _O_U8TEXT or _O_WTEXT
And the nicest part about _O_WTEXT:
"If _O_WTEXT is used to open a file for reading, _open reads the
beginning of the file and check for a byte order mark (BOM).
If there is a BOM, the file is treated as UTF-8 or UTF-16LE
depending on the BOM. If no BOM is present, the file is treated
as ANSI. When a file is opened for writing using _O_WTEXT, UTF-16
is used. If _O_UTF8 is used, the file is always opened as UTF-8
and if _O_UTF16 is used, the file is always opened as UTF-16
regardless of any previous setting or byte order mark."
No extra libraries (sorry Giovanni :-) and no need to do your own conversion
(sorry Tom :-)
--
Mihai Nita [Microsoft MVP, Visual C++]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
.
- Follow-Ups:
- Re: unicode file
- From: Tom Serface
- Re: unicode file
- From: Giovanni Dicanio
- Re: unicode file
- Prev by Date: Re: Dialog size in pixel
- Next by Date: Re: Dialog size in pixel
- Previous by thread: Re: unicode file
- Next by thread: Re: unicode file
- Index(es):
Relevant Pages
|