sprintf function and Cyrillic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-01-13 9: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'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-01-14 1: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-01-14 3:14 AM
I need a single-byte mode with Cyrillic characters. How can I do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-01-15 2: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-01-15 7:13 PM
Pavel A. How do I add cp866 to stm32cubeide?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-01-16 3: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-01-16 4: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....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-01-16 5:52 AM
Do not add -fexec-charset=CP1251. Just compile as is. Source with CP866 strings compiles for me with gcc v7 in Linux.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-01-16 7:17 AM
I'm a novice programmer. Explain in more detail. How did you enable cp866?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-01-17 10:54 AM
