F
flywav
hi all
you know unicdoe is very important, under linux, i always use
utf-8, but now i need save one file in unicode. my linux is centos.
and i know this system support unicode. the wchar_t *p is a unicode
string, i print the len it is 7. it is right,i save the file, the
file length is 7. i had checked it, it is'hello??' ? = 0x3F, so
what's wrong with these code? thank you.
#define __STDC_ISO_10646__ 200104L
#include <wchar.h>
#include <stdio.h>
#include <stdlib.h>
#define _TEXT(x) L ## x
int main() {
FILE *fp = NULL;
wchar_t *filename = _TEXT("oov.txt");
wchar_t *p = _TEXT("helloÄãºÃ");
wprintf(_TEXT("%S\n"), p);
wprintf(_TEXT("%d \n"), wcslen(p));
fp = fopen( "oov.txt", "w");
fwprintf(fp, _TEXT("%S"), p);
fclose(fp);
return 0;
}
my locale
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
you know unicdoe is very important, under linux, i always use
utf-8, but now i need save one file in unicode. my linux is centos.
and i know this system support unicode. the wchar_t *p is a unicode
string, i print the len it is 7. it is right,i save the file, the
file length is 7. i had checked it, it is'hello??' ? = 0x3F, so
what's wrong with these code? thank you.
#define __STDC_ISO_10646__ 200104L
#include <wchar.h>
#include <stdio.h>
#include <stdlib.h>
#define _TEXT(x) L ## x
int main() {
FILE *fp = NULL;
wchar_t *filename = _TEXT("oov.txt");
wchar_t *p = _TEXT("helloÄãºÃ");
wprintf(_TEXT("%S\n"), p);
wprintf(_TEXT("%d \n"), wcslen(p));
fp = fopen( "oov.txt", "w");
fwprintf(fp, _TEXT("%S"), p);
fclose(fp);
return 0;
}
my locale
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=