Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1071

Is the gcc compiler that is responsible for storing ( in the executable ) utf8 characters from a C language char array?

$
0
0

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 ?


Viewing all articles
Browse latest Browse all 1071

Trending Articles