Chinese characters

xiaoxiao2021-03-06  38

Many C-language reference books have not been involved in this problem. There are many English variables and English strings. Of course, storage Chinese characters should use characters, this is certain, key issues are Chinese characters in your computer system. How do you have a few bytes? You know the size with this statement:

Printf ("% d", strlen ("size"))); // Enter the size of 2 Chinese characters

However, the size of Chinese characters in each system is different, and fortunate is the same size in most systems. But I have to pay attention to the half-corner and full-corner of Chinese characters. Oh, then I use a simple example to illustrate the input and output of Chinese characters: #include using namespace std;

INT main () {char A [3]; cin >> a; cout << a; return 0;}

Enter: Yes Yes: Yes

Another program is to identify Chinese characters to realize a copy

/ * This is the mechanism of Chinese character encoding. For a very English code distinction. In general, when the first byte is 1, the default this byte and one byte are combined to form a Chinese character ~ * / #include #include #define size 3void my_strcopy (char des n); INT i = strlen (s); if (n> = i) / / If n is larger than I, copy it directly. {STRCPY (DEST, S); RETURN;} INT FLAG = 0; // Add a flag, used to mark the number of bits of the Chinese added in (int J = 0; j

转载请注明原文地址:https://www.9cbs.com/read-71459.html

New Post(0)