I'm on an Ubuntu system and I wrote this simple program :
#include <unistd.h>#include <sys/stat.h>#include <fcntl.h>#include <stdio.h>int main( void ){ char utf8_arr[] = "写一个名字列表: \n\n"; write(1,utf8_arr,sizeof(utf8_arr)); char utf8_buff[1024]; ssize_t r; while ( (r = read(0,utf8_buff,sizeof(utf8_buff))) > 0 ){ write(1,utf8_buff,r); } return 0;}
My questions :
1)Who controls the character encoding ( the way actual characters are stored in memory ) when it comes to C language strings like the one in my program ? Is it the gcc compiler ( that in turn gets its own character encoding settings from somewhere ) ?
2)Is it 100% correct to use utf8 char string just for storing ,writing and reading the way my program does ?
3)What about sizeof ? Is it fine to use it like this ?