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

GCC: making UTF-8 the execution character set

$
0
0

I wrote this test program in a Latin-1 encoded file...

#include <cstring>#include <iostream>using namespace std;const char str[] = "ÅÄÖ";int main() {  cout << sizeof(str) << ''<< strlen(str) << ''<< sizeof("Åäö") << ''<< strlen("åäö") << endl;  return 0;}

...and compiled it with g++ -fexec-charset=UTF-8 -pedantic -Wall on OpenBSD 5.3. I was expecting to see the size of the strings being 6 chars + 1 NUL char, but I get the output 4 3 4 3?

I tried changing my system locale from ISO-8859-1 to UTF-8 with export LC_CTYPE=sv_SE.UTF-8, but that didn't help. (Accordning to the gcc manual, that only changes the input character set, but hey, it was worth a try.)

So, what am I doing wrong?


Viewing all articles
Browse latest Browse all 1052

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>