I have problem in working with strings in pure C lang (c89 standard). I receive some text from web service using sockets in utf8 format. Everything is ok with latin character. But I also have some cyrillic. And it is shown something like В переданном
. How to convert utf8
text with cyrillic to char *
in pure C?
Asked
Active
Viewed 261 times
-1

HelloWorld123456789
- 5,299
- 3
- 23
- 33

salvicode
- 227
- 2
- 12
-
Saying "to char*" is the same as saying "to memory" - i.e. it does not make sense until you specify the target encoding (for example, КОИ-8). – Sergey Kalinichenko Apr 02 '14 at 08:40
-
what do you do with the text you receive? put it to a file? process it? display it on terminal? – tejas Apr 02 '14 at 08:42
-
If I debug and use watch list it shows Ð’ переданном. So if I use this text later to display it it will be wrong... – salvicode Apr 02 '14 at 08:43
-
first of all - you should find out, what encoding you want in result. – Ryzhehvost Apr 02 '14 at 08:50
-
you can dump everything in a file and open it in a text editor like notepad++, i think it is not showing correctly might be because windows supports utf-16 not utf-8 – tejas Apr 02 '14 at 11:08
1 Answers
2
You can't convert UTF-8 to char *
, as char *
doesn't have a prescribed format and one of the most common formats for char *
is actually UTF-8. If you encounter any other encoding, you can use the good old standard iconv.

Pavel Šimerda
- 5,783
- 1
- 31
- 31