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 / .NET Framework / CLR / November 2005

Tip: Looking for answers? Try searching our database.

Unicode IsLetter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ThorstenJ - 29 Nov 2005 11:38 GMT
 I'm not sure in which discussion this fits in, but I'll try here.
I need to use Unicode in order to use national characters. But I
find a strange behavior that I had not expected. I can't find much from
the documentation about this. I need to know if a character is a letter or
not.
Even if it is a national character. I have tried this code:
    Console::WriteLine(System::Char::IsLetter('A') );
    Console::WriteLine(System::Char::IsLetter('É') );
    Console::WriteLine(System::Char::IsLetter('é') );
    Console::WriteLine(System::Char::IsLetter('Ö') );

I was expecting to get the result
True
True
True
True

But that is not what I get, I get this.
True
False
False
True

 Why do I get False from System::Char::IsLetter('É')

Is there another way to know if a Char is letter or not?

Thorsten
Mattias Sjögren - 29 Nov 2005 13:19 GMT
>   Why do I get False from System::Char::IsLetter('É')
>
> Is there another way to know if a Char is letter or not?

Because chars by default are signed 8-bit (unless you're compiling with /J)
and since 'É' > 127 it compiles to a negative number which then when cast to
an System::Char (or unsigned wchar_t) ends up as something like 0xff??. You
probably want

Console::WriteLine(System::Char::IsLetter(L'É') );

Mattias

Rate this thread:







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.