I have a C program that currently reads in Chinese text and stores them as type wchar_t
. What I want to do is look for a specific character in the text, but I am not sure how to refer to the character in the code.
I essentially want to say:
wchar_t character;
if (character == 个) {
return 1;
}
else return 0;
Some logic has been omitted, obviously. How would I go about performing such logic on Chinese in C?
Edit: Got it to work. This code compiles with -std=c99, and prints out the character "个".
1 #include <locale.h>
2 #include <stdio.h>
3 #include <wchar.h>
4
5
6 int main() {
7 wchar_t test[] = L"\u4E2A";
8 setlocale(LC_ALL, "");
9 printf("%ls", test);
10 }