[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

System.Char.IsNumber is either buggy or documentation is very poor.

BrianM

12/14/2002 3:29:00 PM

When I read the doc for the Char.IsNumber() method it says:
"Indicates whether the specified Unicode character is categorized as a
decimal digit or hexadecimal number."

So I would think that it is a direct replacement for the old trustworthy C
routine isxdigit() and that it would return true for 0-9, a-f, and A-F.
However, when I do the following:

bool b1 = Char.IsNumber('d');

bool b2 = Char.IsNumber('D');

bool b3 = Char.IsNumber('5');

I get b1 = false, b2 = false, b3 = true.

It's a little scary that something this simple hasn't been discovered by
service pack 2 .





4 Answers

NETMaster

12/14/2002 5:00:00 PM

0

It's a documentation bug !

Fixed in VS.NET 2003 final beta doc:

Char.IsNumber Method
Indicates whether a Unicode character is categorized as a number.


--
Thomas Scheidegger - MVP .NET - 'NETMaster'
http://www.cetus-links.org/oo_d... - http://dnetm...


BrianM

12/15/2002 3:03:00 PM

0

Do you know if there is a replacement for isxdigit() or do I have to roll my
own.?


"Thomas Scheidegger [MVP] NETMaster" <spam.netmaster@swissonline.ch> wrote
in message news:O1hOgn4oCHA.2764@TK2MSFTNGP09...
> It's a documentation bug !
>
> Fixed in VS.NET 2003 final beta doc:
>
> Char.IsNumber Method
> Indicates whether a Unicode character is categorized as a number.
>
>
> --
> Thomas Scheidegger - MVP .NET - 'NETMaster'
> http://www.cetus-links.org/oo_d... - http://dnetm...
>
>


NETMaster

12/16/2002 12:03:00 AM

0

> a replacement for isxdigit()

.NET uses the Unicode categories:

http://www.unicode.org/unicode/rep...
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemGlobalizationUnicodeCategoryClas...
=> no hex

And there is Regex, but IMHO it is a bit 'heavy' for a simple check for hex digits...


But there is a simple :
bool Uri.IsHexDigit( char )
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemUriClassIsHexDigi...
and this one should be fast, it does a simple check: 0..9, A..F, a..f


--
Thomas Scheidegger - MVP .NET - 'NETMaster'
http://www.cetus-links.org/oo_d... - http://dnetm...


Thong Nguyen <tum(NOSPAM

12/16/2002 8:49:00 PM

0

Ugh. I really have to question why IsHexDigit wasn't moved from the Uri
class to the Char class early in the beta. Another case of poor class
library design in .NET :-(.

^Tum

"Thomas Scheidegger [MVP] NETMaster" <spam.netmaster@swissonline.ch> wrote
in message news:emmqj4IpCHA.1888@TK2MSFTNGP09...
> > a replacement for isxdigit()
>
> .NET uses the Unicode categories:
>
> http://www.unicode.org/unicode/rep...
>
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemGlob...
nicodeCategoryClassTopic.asp
> => no hex
>
> And there is Regex, but IMHO it is a bit 'heavy' for a simple check for
hex digits...
>
>
> But there is a simple :
> bool Uri.IsHexDigit( char )
>
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemUriC...
igitTopic.asp
> and this one should be fast, it does a simple check: 0..9, A..F, a..f
>
>
> --
> Thomas Scheidegger - MVP .NET - 'NETMaster'
> http://www.cetus-links.org/oo_d... - http://dnetm...
>
>