'How to do direct assignment of string with a special character in C
I find it quite useful that I can do this in C:
char *text;
text = "5 us";
However, when I try to do this
char *text;
text = "5 µs";
I get an extraneous character due to the source code encoding in UTF-8 in Eclipse (using CubeIDE). So the string looks like this in byte form:
0x35 0x20 0xC2 0xB5 0x73 0x00
I need the 0xC2 removed and I don't want to write a function to remove this character. I know I can configure Eclipse to handle my source code in US-ASCII. However, then I cannot save my file anymore because of the given assignment
text = "5 µs";
Eclipse won't save my file unless I remove the µ in my source code.
Is there maybe something like the following?
text = {'5', ' ', 181, 's', '0');
I just don't want to go through the hoops of creating a global string the pedestrian way. I want to preserve the elegance of a direct assignment.
Sorry if I don't use the proper C terms but I think you get the gist.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
