Question

when i use non-ascii character for defining global array, for example:

const char table[] = {[L'č'] = 'c', ...}; 

so C handles situation, where i change locale and then access array through those indexes? How this is compiled? Because 'č' has different value in different encodings.

Was it helpful?

Solution

The compiler should convert the character in the source code from the source code encoding to the execution wide character set, which is chosen at compile time. The values will then be constants with the integer value of whatever that character is in that encoding. Calls to setlocale() will not have any effect on the values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top