Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2007

Tip: Looking for answers? Try searching our database.

Obtaining the unicode for an exotic character - please help!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
almurph@altavista.com - 15 Oct 2007 16:59 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.