Re: unicode file



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
.



Relevant Pages

  • Re: CStdioFile is broken in about 6 ways
    ... I've seen is an extension by our Tom; he developed code which can manage ... I'll be glad to *write* UTF-8 in this particular case because my ... CStdioFile is not good for ANSI? ... And I think that at least standard C run-time library file functions (like ...
    (microsoft.public.vc.mfc)
  • Re: ????,?????
    ... That is prety vague. ... Looks like Unicode converted to ANSI without the right ... Tom ... Prev by Date: ...
    (microsoft.public.vc.mfc)
  • Re: unsigned long long
    ... >> ANSI is old. ... I for one welcome our new ISO overlords. ... Be that as it may "unsigned long long" is part of ISOC AFAIK. ... Tom ...
    (comp.lang.c)