H.Ghassami
H.Ghassami

Reputation: 1022

How to convert Persian character in decimal value in c++?

I work with Persian language(UTF-8). I want to convert it to hex. but my problem is first How to convert Persian character in decimal value in c++ in Linux OS?(I used Qt creator)

Upvotes: 2

Views: 469

Answers (2)

Murali Manohar
Murali Manohar

Reputation: 613

You can convert persian text to hex with this code

  byte[] yourStrBytes = Encoding.GetEncoding("your encoding").GetBytes("your str");
  string hexStr = BitConverter.ToString(yourStrBytes).Replace("-", "");

Upvotes: 0

cliffordheath
cliffordheath

Reputation: 2606

The characters you mention have a three-byte encoding. If you are storing UTF-8 in an array of char, then you need to convert each byte to hex. Otherwise you might want to convert the 3-byte UTF-8 encoding to UTF-16 (16-bit integer, similar to UCS-2) encoding, and display the hex value of that 16-bit result.

Upvotes: 1

Related Questions