   UTF16 and text file
  Hi, I do some research here on gamedev about unicode but no post really help me to resolve my problem.I'm trying to write strings to unicode text files. I write the Bom FEFF to indicate that i'm writting a UTF16 text file and i writte strings with fwprintf (or fputws).The problem is that fwprintf does not writte UTF16 charactere (it seems) but somethings like UTF8 or pseudo-ASCII i don't know (a conversion seems to be done... the charactere only weigh 1 byte finally...) Is this possible to write UTF16 strings with C standard functions ? how writte UTF16 strings in a text file ?   
  Well, I'm not sure about the behaviour of MS functions and MSDN seems a bit unclear about exactly what fwprintf does output. If you're only worried about MS operating systems you should be able to get this to work using swprintf and fwrite, but in fact this is pretty much certain not to work on any non-MS operating system because wchar_t on most other OSes is 32-bit rather than 16-bit. (I believe this is technically more accurate since there are a small number of characters which don't fit inside 16 bits - these can be encoded in UTF-16 using a two word code, but obviously can't be held in one 16-bit wchar_t).Anyway I can't remember their names but I'm sure somebody else on here can recommend a good and free Unicode library.   ;  *Erf* i don't understand why fwrite doesnt work too. It seems that \n caracteres for exemple are not well coded in L"" string (not UTF16)... But i'm really not sure of what i said..I really don't arrive to write L"" style string in a UTF16 text file.. If someone have code that work, please post it ^^EDIT: on both linux and windows   ;  I've been doing some unicode research too, and some time ago I found this:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_unicode.99_.stream_i.2f.o_in_text_and_binary_modes.aspBasically it says that if you open the file in text mode, all characters will be written in ascii mode, regardless if you use fprintf or fwprintf.To be able to write in true unicode, you have to open the file in binary mode, so the data is written directly to the file, without conversion.Hope it helps   ;Quote:Original post by vicviperI've been doing some unicode research too, and some time ago I found this:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_unicode.99_.stream_i.2f.o_in_text_and_binary_modes.aspBasically it says that if you open the file in text mode, all characters will be written in ascii mode, regardless if you use fprintf or fwprintf.To be able to write in true unicode, you have to open the file in binary mode, so the data is written directly to the file, without conversion.Hope it helpsYes I saw but it changed nothing in binary mode, the conversion seems to be done too...I see that with an hexadecimal editor..   ;  Ok sorry, this is exactly that, it must be open in binary mode...Thank you !   