Unicode Code of a chracter
-
How can I find a Unicode Code of a chracter in a string For exmple Unicode of (њ) is 5A 04 Is there any way to find it programmatically
Hello Friends
-
You can use the Encoding class, like this:
byte[] bytes = Encoding.UTF8.GetBytes("њ");
I haven't tested it, so the syntax might be a little bit different. regards -
How can I find a Unicode Code of a chracter in a string For exmple Unicode of (њ) is 5A 04 Is there any way to find it programmatically
Hello Friends
-
Thanks alot. it worked Now I want to convert this code to hex. How can I do it?
Hello Friends
-
Characters are unicode, so you can just convert it to int:
int code = (int)'њ';
Despite everything, the person most likely to be fooling you next is yourself.
-
SK Genius wrote:
.ToString('X');
That works fine - I prefer Convert.ToString(value, base) as you don't have to remember the silly string formats and you can specify base 2, 8, 10 or 16 so is more flexible. :-D
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Expect everything to be hard and then enjoy the things that come easy. (code-frog) -
It is probably better to use:
char.ConvertToUtf32(string, int)
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)but why? i also usually cast the char to int to get its unicode value
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.passion != Programming)
-
but why? i also usually cast the char to int to get its unicode value
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL
you.suck = (you.passion != Programming)
Harvey Saayman wrote:
but why?
Because .NET has Unicode surrogate pairs, meaning sometimes it takes 2 combined characters to form a complete Unicode code point.
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)