2021-01-13 09:28 PM
I ran into the following problem the sprintf(str, "привет") function; encodes in a two-byte format. Each even character = 208 (dec).
str[0] char 208 '�?'
str[1] char 159 '\237'
str[2] char 209 'Ñ'
str[3] char 128 '\200'
str[4] char 208 '�?'
str[5] char 184 '¸'
str[6] char 208 '�?'
str[7] char 178 '²'
str[8] char 208 '�?'
str[9] char 181 'µ'
str[10] char 209 'Ñ'
str[11] char 130 '\202'
2021-01-14 01:36 AM
Привет, Alex,
this is because Cyrillic is not part of the ASCII character set, but rather of Unicode and therefore requires two bytes per character.
И�?кренне Ваш
/Peter
2021-01-14 03:14 AM
I need a single-byte mode with Cyrillic characters. How can I do this?
2021-01-15 02:39 PM
Use single byte encoding such as CP866 https://en.wikipedia.org/wiki/Code_page_866
But to display it you'll need a terminal that can render it.
-- pa
2021-01-15 07:13 PM
Pavel A. How do I add cp866 to stm32cubeide?
2021-01-16 03:32 AM
I don't know. Eclipse once supported non-unicode encodings, you can ask in Eclipse mailing list how to get it back.
You even do not have to use Eclipse as editor, use whatever works.
The gcc compiler should accept one byte encoding if you don't coerce it to interpret the source as unicode (with L"..." or u8"..." strings)
Another option - do not use cyrillic in your C source files, keep the Cyrillic strings as "resources" elsewhere.
-- pa
2021-01-16 04:08 AM
I tried adding the command gcc-fexec-charset=CP1251 to project ---> properties ---> c/c++ build ---> settings ---> MCU C Compiler ---> gcc -fexec-charset=CP1251.
Got errors
make: *** [Src/subdir.mk:89: Src/main.o] Error 1
make: *** Waiting for unfinished jobs....
2021-01-16 05:52 AM
Do not add -fexec-charset=CP1251. Just compile as is. Source with CP866 strings compiles for me with gcc v7 in Linux.
2021-01-16 07:17 AM
I'm a novice programmer. Explain in more detail. How did you enable cp866?
2021-01-17 10:54 AM