I know that the -fexec-charset=charset flag for compiled Linux systems will probably be the default UTF-8. My question is: How do I verify that? Is there some /proc variable which will tell me that?
The rationale behind my question is that system calls which take char * as a parameter expect the encoding to be in the same format as the compiled kernel. The safest way would be to use the kernel provided variable as a parameter for compiling an application doing system calls.
Note that this is independent of the system locale.
Added sample program to illustrate the isssue:
Code:
const char * file_name = "/tmp/有難う.txt";
int main(void) {
if (open(file_name, 0) < 0) {
perror("failed to open file");
} else {
perror("opened file");
}
return 0;
}
Code:
$ touch /tmp/有難う.txt
$ gcc -fexec-charset=UTF-8 source.c && ./a.out
opened file: Success
$ gcc -fexec-charset=UTF-16 source.c && ./a.out
��f: No such file or directory