Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the value of UTF-8 character

Tags:

c

utf-8

I have an utf-8 character in chinese or arabic language. I need to get the value of that UTF-8 character, like getting a value of ASCII character. I need to implement it in "C". Can you please provide your suggestions?

For example:

char array[3] = "ab";
int v1,v2;

v1 = array[0];
v2 = array[1];

In the above code I will get corresponding ASCII values in v1 and v2. In the same way for UF8 string I need to get the value for each character in a string.

like image 618
2vision2 Avatar asked Dec 27 '12 14:12

2vision2


1 Answers

Only the C11 standard version of the C language offers UTF-8 support, so depending on what standard you are targeting, you can use the C11 features (<uchar.h>) or rely on a UTF library such as ICU.

like image 92
user1824407 Avatar answered Oct 31 '22 20:10

user1824407