I want to check if a character is a decimal digit (0-9).
I've found Char.IsNumber() and Char.IsDigit() but couldn't work out from Help how they differ.
Also, do I need to worry about how digits get converted when typed into keyboards in different
countries? Can I assume that Char.IsNumber() and Char.IsDigit() cope with this? 7 3671
<"Jay" <nospam>wrote:
I want to check if a character is a decimal digit (0-9).
I've found Char.IsNumber() and Char.IsDigit() but couldn't work out
from Help how they differ.
From the docs for IsNumber:
<quote>
This method determines if a Char is of any numeric Unicode category.
This contrasts with IsDigit, which determines if a Char is a radix-10
digit.
Valid numbers are members of the following categories in
UnicodeCategory: DecimalDigitNumber, LetterNumber, or OtherNumber.
</quote>
Also, do I need to worry about how digits get converted when typed
into keyboards in different countries? Can I assume that
Char.IsNumber() and Char.IsDigit() cope with this?
The input method is irrelevant to the value when you've got it as a
character.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Thanks Jon, but it's still not clear to me - what you have quoted is what I read in Help, which I
didn't understand.
What is meant by "any numeric Unicode category"? Does that mean decimal digits 0-9 AND some other
characters too? If so, what are the other characters?
"The input method is irrelevant to the value when you've got it as a character" ...but the character
is from a string which comes from a keyboard.
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
<"Jay" <nospam>wrote:
I want to check if a character is a decimal digit (0-9).
I've found Char.IsNumber() and Char.IsDigit() but couldn't work out
from Help how they differ.
From the docs for IsNumber:
<quote>
This method determines if a Char is of any numeric Unicode category.
This contrasts with IsDigit, which determines if a Char is a radix-10
digit.
Valid numbers are members of the following categories in
UnicodeCategory: DecimalDigitNumber, LetterNumber, or OtherNumber.
</quote>
Also, do I need to worry about how digits get converted when typed
into keyboards in different countries? Can I assume that
Char.IsNumber() and Char.IsDigit() cope with this?
The input method is irrelevant to the value when you've got it as a
character.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
<"Jay" <nospam>wrote:
Thanks Jon, but it's still not clear to me - what you have quoted is
what I read in Help, which I didn't understand.
What is meant by "any numeric Unicode category"? Does that mean
decimal digits 0-9 AND some other characters too? If so, what are the
other characters?
Yes, there are other types of number characters, in the categories
LetterNumber and OtherNumber, as specified. www.unicode.org could
probably give you more information.
"The input method is irrelevant to the value when you've got it as a
character" ...but the character is from a string which comes from a
keyboard.
But if the character is '0' it doesn't matter what keys they had to
press in order to get that character.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
A quick reference for unicode number,letter category: http://www.fileformat.info/info/unic...ry/Nl/list.htm
For these, IsNumber returns true whereas IsDigit returns false. For example.
IsNumber returns true when IsDigit returns true, but not vice versa.
The performance seems the same to me, so why not just use IsNumber and leave
IsDigit.
"Jon Skeet [C# MVP]" <sk***@pobox.comha scritto nel messaggio
news:MP************************@msnews.microsoft.c om...
<"Jay" <nospam>wrote:
>Thanks Jon, but it's still not clear to me - what you have quoted is what I read in Help, which I didn't understand.
What is meant by "any numeric Unicode category"? Does that mean decimal digits 0-9 AND some other characters too? If so, what are the other characters?
Yes, there are other types of number characters, in the categories
LetterNumber and OtherNumber, as specified. www.unicode.org could
probably give you more information.
>"The input method is irrelevant to the value when you've got it as a character" ...but the character is from a string which comes from a keyboard.
But if the character is '0' it doesn't matter what keys they had to
press in order to get that character.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Thanks again for your help Jon.
It sounds like I need to use IsDigit, since I don't want these other characters.
"But if the character is '0' it doesn't matter what keys they had to press in order to get that
character."
I wondered if there are different types of decimal digits, apart from those in Ascii. Unicode
confuses me - are there lots of representations of '0', or just one (the Ascii one?
Jay
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
<"Jay" <nospam>wrote:
Thanks Jon, but it's still not clear to me - what you have quoted is
what I read in Help, which I didn't understand.
What is meant by "any numeric Unicode category"? Does that mean
decimal digits 0-9 AND some other characters too? If so, what are the
other characters?
Yes, there are other types of number characters, in the categories
LetterNumber and OtherNumber, as specified. www.unicode.org could
probably give you more information.
"The input method is irrelevant to the value when you've got it as a
character" ...but the character is from a string which comes from a
keyboard.
But if the character is '0' it doesn't matter what keys they had to
press in order to get that character.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
<"Jay" <nospam>wrote:
Thanks again for your help Jon.
It sounds like I need to use IsDigit, since I don't want these other
characters.
Right. I strongly suspect you're right.
"But if the character is '0' it doesn't matter what keys they had to
press in order to get that character." I wondered if there are
different types of decimal digits, apart from those in Ascii. Unicode
confuses me - are there lots of representations of '0', or just one
(the Ascii one?
AFAIK, there's only one decimal digit '0' character.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Laura: thanks for the useful link. I don't want the function to pick up on things that IsNumber does
(eg Roman numerals, such as i, v, x) so I'll use IsDigit.
Jay
"Laura T." <LT@NOWHERE.COMwrote in message news:eq**************@TK2MSFTNGP06.phx.gbl...
A quick reference for unicode number,letter category: http://www.fileformat.info/info/unic...ry/Nl/list.htm
For these, IsNumber returns true whereas IsDigit returns false. For example.
IsNumber returns true when IsDigit returns true, but not vice versa.
The performance seems the same to me, so why not just use IsNumber and leave
IsDigit.
"Jon Skeet [C# MVP]" <sk***@pobox.comha scritto nel messaggio
news:MP************************@msnews.microsoft.c om...
<"Jay" <nospam>wrote:
>Thanks Jon, but it's still not clear to me - what you have quoted is what I read in Help, which I didn't understand.
What is meant by "any numeric Unicode category"? Does that mean decimal digits 0-9 AND some other characters too? If so, what are the other characters?
Yes, there are other types of number characters, in the categories
LetterNumber and OtherNumber, as specified. www.unicode.org could
probably give you more information.
>"The input method is irrelevant to the value when you've got it as a character" ...but the character is from a string which comes from a keyboard.
But if the character is '0' it doesn't matter what keys they had to
press in order to get that character.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Batista, Facundo |
last post by:
Here I send it.
Suggestions and all kinds of recomendations are more than welcomed.
If it all goes ok, it'll be a PEP when I finish writing/modifying the code.
Thank you.
.. Facundo
|
by: Mark |
last post by:
Hi - can anyone give me a sample of how I would ensure a value in a text
box was a decimal (it is used for entering money - so has to check for
no more than 2 decimal places, but still allow should...
|
by: hana1 |
last post by:
Hello experts,
I used to program in C/C++ and now switched to Java. I am having a
difficulty that I need your help with. How can I limit a double variable to
hold 2 decimal points only? Say I...
|
by: Steve Summit |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
It's often explained that the reason for some of the imprecision
in C's definition is so that C can be implemented on different
kinds of machines -- say, those...
|
by: spebola |
last post by:
I am using vb.net 2003 professional and I get the following results
when using the round method:
dim Amount as decimal = 180.255
Amount = Amount.Round(Amount, 2)
Amount now contains 180.25. ...
|
by: G.Ashok |
last post by:
Hi,
I have created CultureInfo object and specified required digit grouping in
it.
The one of the overloaded ToString methods of Decimal type has parameters to
format the value with required...
|
by: Stefantastisk |
last post by:
Hey there,
Anyone knows a clever method for knowing the length of the digit after
a decimal point in a standard C# decimal value, WITHOUT use of any
string formatting.
Example:
5231,12231 <-...
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
|
by: Jason |
last post by:
I'm making a program that will convert decimal inputs (in this case, in
inches) and output a fractional answer. At the moment, I'm only able to
output the fractional answer in three parts: A whole...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |