Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use special characters in C?

I realized that my program has to be able to handle special characters such as Japanese or Chinese. But I know the built-in type char is far from enough. So how can I use these special characters in C program?

like image 885
OneZero Avatar asked Dec 12 '22 01:12

OneZero


2 Answers

like this in windows VS :)

#include <tchar.h>
typedef struct _我的结构{
    int 数据;
    TCHAR 字符串指针[100];
}我的结构;
int main(int argc,char** argv){
    我的结构 我的变量 = {1, _T("字符串123abc")};
    _tprintf(_T("%s, %d"),我的变量.字符串指针,我的变量.字符串指针);
    return 0;
}
like image 80
RolandXu Avatar answered Dec 21 '22 10:12

RolandXu


You could use UTF-8 encoding if you could live with the fact that one byte != one unicode character.

like image 34
mazatwork Avatar answered Dec 21 '22 09:12

mazatwork