Skip to content

Commit 47a0a56

Browse files
add more docs regarding ideographic numbers
Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent 05e678c commit 47a0a56

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

library/core/src/char/methods.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,16 @@ impl char {
892892
///
893893
/// The general categories for numbers (`Nd` for decimal digits, `Nl` for letter-like numeric
894894
/// characters, and `No` for other numeric characters) are specified in the [Unicode Character
895-
/// Database][ucd] [`UnicodeData.txt`].
895+
/// Database][ucd] [`UnicodeData.txt`]. Note that this means ideographic numbers like '三'
896+
/// are considered alphabetic, not numeric. Please consider to use `is_ascii_digit` or `is_digit`.
897+
///
898+
/// This method doesn't cover everything that could be considered a number, e.g. ideographic numbers like '三'.
899+
/// If you want everything including characters with overlapping purposes then you might want to use
900+
/// a unicode or language-processing library that exposes the appropriate character properties instead
901+
/// of looking at the unicode categories.
902+
///
903+
/// If you want to parse ASCII decimal digits (0-9) or ASCII base-N, use
904+
/// `is_ascii_digit` or `is_digit` instead.
896905
///
897906
/// [Unicode Standard]: https://www.unicode.org/versions/latest/
898907
/// [ucd]: https://www.unicode.org/reports/tr44/
@@ -911,6 +920,7 @@ impl char {
911920
/// assert!(!'K'.is_numeric());
912921
/// assert!(!'و'.is_numeric());
913922
/// assert!(!'藏'.is_numeric());
923+
/// assert!(!'三'.is_numeric());
914924
/// ```
915925
#[must_use]
916926
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)