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 *****
Mattias Sjögren - 15 Oct 2007 20:57 GMT
> 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

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