Saving unicode data to a .txt file

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
i get the same result
and for
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.


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:

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.