Saving unicode data to a .txt file

Hello,
I have a problem when i try to save unicode to a .txt file.
I need to store in a file names that will have letters like "ăĂâÂșȘțȚîÎ"

wchar_t name []=L"ăĂâÂșȘțȚîÎ";
FILE* fang;
fang= _wfopen( L"test.txt",L"wt+,ccs=UNICODE");
fwprintf (fang, L"%ls ",name);


when i open my text file i get this:
??âÂ????îÎ

if i use
fang=fopen("test.txt","a");
i get the same result
and for
fang=fopen("ang.txt","a,css=UNICODE");
i get a runtime eroror "invalid file open mode"

I need to finish this for school but i'm stuck.
This code its for an agenda that has a save option.

Tx

I've never seen that css=UNICODE bit before... a quick google search shows that it's a MSVS specific extension. Interesting.

Anyway... according to the page I found:
http://msdn.microsoft.com/en-us/library/yeby3zcb%28v=vs.90%29.aspx

UNICODE is a bit misleading. If you open a new file and specifiy css=UNICODE it will not create a unicode file, but instead will create an ANSI file. (see the "Encodings Used Based on Flag and BOM" chart on that page)

So instead, you should probably use css=UTF-8 or css=UTF-16LE... depending on which one you want.
It worked with UTF-8 and UTF-16LE.
Thanks a lot.
That was the problem.
ANSI its an extension of ASCII character set and it doesn't have "ăĂ ÂșȘțȚ".
That tag "css=UNICODE" its very misleading.
Topic archived. No new replies allowed.