5
I’m having a hard time understanding why the Clang presents the error message
Character Too large for enclosing Character literal type
when trying to execute the code:
char c = 'ç';
while Visual Studio 2015 compiles smoothly. I know that different compilers can and have their different implementations. And that ç is outside the ASCII table, that the numerical value must be greater than 127 so Clang informs that it is not possible to store within the type char
. But I’d still like to know:
Why doesn’t Clang allow me to use 'ç' as a char while Visual Studio allows it? Is it something predefined in Visual Studio? Some language based option of my system?
Because Visual Studio returns the "correct" value in the functions of string
, as strlen
even passing strings with accents?
Example: strlen("opção");
Returns 5 in Visual Studio, I expected the return to be 7 as Clang returns.
I would venture that because this character does not belong to the ASCII standard it occupies more than 1 byte (while the type
char
only supports this size). See if there is any option to consider the source code as UTF-8 when running.– Jônatas Hudler
Yes, I believe it is that in the Clang, there the strlen returns the value in bytes, or it is more than 1 byte for ç. From what I saw gcc allows changing the encoding, but the Clang does not have such option. But what intrigues me is that Visual Studio simply works without any kind of warning for characters outside the ascii table. Even using extended ascii.
– Pedro Henrique