Answer the question
In order to leave comments, you need to log in
How to write Cyrillic and symbols of other languages to a text file?
Hello. There was a problem: you need to write the file names (I have an array of wchar_t ** filenames) into a text file. With English names, everything is fine, the problem is with all other alphabets. Prompt a method how to implement record for all languages.
Answer the question
In order to leave comments, you need to log in
who is interested, solved the problem with this function
WideCharToMultiByte(CP_ACP,WC_COMPOSITECHECK,wfilename[0],-1,chName1,sizeof(chName1),NULL,NULL)
In fact, it is correct to write all the same through streams, you only need to set the locale settings as expected.
With Visual Sudio, everything is simple:
std::locale::global(std::locale("Russian"));
std::wcout << L"привет";
CP_ACP
instead ofCP_OEM
Deal with encodings first, Windows loves UTF-16 (actually UCS-2), while posix systems are UTF-8. UTF-8 is essentially stored in a regular char, it is a multi byte encoding, the character size is floating from 1 to 4 bytes, it is more difficult to work with these strings. UTF-16 is always a 2-byte character set, stored in wchar_t. As a result, with UTF-8, all the same writing methods are used as for regular ANSI (std:: ofstream), in general, if character-by-character work is not required, then all ANSI methods are suitable. Whereas UTF-16 uses its own methods, objects (std::wofstream). Well, their heirs. In parentheses, I indicated the streams that can be saved.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question