Navaneeth K N
Navaneeth K N

Reputation: 15501

Getting character from the Unicode code-point - C++

I have got two questions.

1 - I get Unicode code-points and how do I get the character associated with this code-point? Something like:

int code_point = 0xD24;
char* chr = (char*) code_point;

But the above code fails by throwing exception.

2 - Suppose the code-point is stored in a file and I read the code-point to a string, how do I convert that to valid Unicode string?

I am looking for a platform independent solution. Any help would be great!

Upvotes: 1

Views: 2015

Answers (3)

Steven R. Loomis
Steven R. Loomis

Reputation: 4350

Are you looking for the name of the character? u_charName() in ICU will do this, returning something like LATIN SMALL LETTER A.

Upvotes: 0

John Lockwood
John Lockwood

Reputation: 3875

Don't you mean to be assigning that value to a char (or more precisely, to a wchar_t), not a char* ?

Upvotes: 1

Vijay Mathew
Vijay Mathew

Reputation: 27174

Have you looked at the International Components for Unicode project? As per the site,

ICU is a mature, widely used set of C/C++ and Java libraries providing Unicode and Globalization support for software applications. ICU is widely portable and gives applications the same results on all platforms and between C/C++ and Java software.

Upvotes: 4

Related Questions