What are the application skills of C++ 's input and output of Chinese characters
What this article shares with you is about the application skills of C++ input and output Chinese characters. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Let's take a look at it with the editor.
In C++ programming language, there are many ways to deal with Chinese characters, developers can choose a suitable way according to their different needs. For example, the implementation method of C++ input and output Chinese characters introduced to you today is one of the relatively simple ways.
When using L macros in C++, it is only said to be wide characters, but it is not necessarily Unicode. That is to say, the programmer has to set the specific character set to be used. This is the function of imbue. It is also the problem that you cannot input Chinese characters in your file. You just need to set it as follows:
In.imbue (locale ("chs")); in > > text; out.imbue (locale ("chs")); outtext; in.close (); out.imbue (locale ("chs")); out.open ("output.txt"); out