izb
izb

Reputation: 51761

How do I convert a 16-bit UCS-2 integer value into a char?

I am parsing values from a binary file. One value I am parsing is a 16-bit number which represents the UCS-2 encoding of a unicode character. I'm converting it to a character like this:

char c = (char)myInteger;

Is this safe?

Upvotes: 1

Views: 820

Answers (1)

unwind
unwind

Reputation: 399793

Yes, as long as there are no byte-ordering issues this should be fine.

Upvotes: 2

Related Questions