Obtaining the unicode for an exotic character - please help!

A

almurph

Hi,

Hope that you can help me here. I'm trying to write a little windows
appliction that takes essentially calculates and displays the VB.NET
"ChrW()" code for an exotic character (mainly east European languages
like the cadilla, ogonek etc, not Chinese or anything like that).

For example, say I cut an paste the exotic character: latin capital U
with Diaeresis into a field. Is it possible to write code to get the
little-endian uncode encosing for this

Latin Capital Letter U with Diaeresis (U+00DC) ---> &H00DC

So if I then do:

ChrW(&H00DC) ----> I get : Latin Capital Letter U with Diaeresis


In other words, I'm looking for nice way to generate the unicode of a
character that I cut and paste into a textbox.


I know how to convert a string into a byte array (that's easy - code
below) but after that I start to get stuck. Can you help me please?
Any comments/suggestions/comments/code-samples much appreciated...

Cheers,
Al.


***** BEGIN CODE SAMPLE *****

Public Shared Function StrToByteArray(ByVal str As String) As Byte()
Dim encoding As New System.Text.UnicodeEncoding 'UTF-16
Return encoding.GetBytes(str)
End Function


**** END *****
 
M

Mattias Sjögren

I know how to convert a string into a byte array (that's easy - code
below) but after that I start to get stuck. Can you help me please?

You're making it more complicated than it has to be. A string has an
indexer so you can treat it as a Char array. Given the Char you want
you can simply treat it as an integer and print it in hexadecimal
format. So all you need is

str(0).ToString("X")


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top