By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,693 Members | 1,799 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,693 IT Pros & Developers. It's quick & easy.

Obtaining the unicode for an exotic character - please help!

P: n/a
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 *****

Oct 15 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> 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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Oct 15 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.