arowM/elm-decimal-char/1.0.0

NOTE: the latest version is 2.0.0

DecimalChar

Provide functions to handle Unicode decimal characters, which are listed in DerivedNumericType-15.0.0.txt as Numeric_Type=Decimal.

You can use this library to normalize user inputs, which will free users from the hassle of entering numbers in the "correct" format.

isNumeral : Char -> Bool

Check if a character is decimal (i.e., `Numeric_Type=Decimal).

isNumeral '3'
--> True


isNumeral '3'
--> True


isNumeral '🐐'
--> False


-- Roman digit is numeric, but not decimal.
isNumeral 'Ⅵ'
--> False
isBasicLatin : Char -> Bool

Check if a character is the Basic Latin digit (i.e., between 0x0030 and 0x0039 in code points).

isBasicLatin '3'
--> True


isBasicLatin '3'
--> False
toBasicLatin : Char -> Maybe Char

Convert a character to the corresponding Basic Latin digit character.

If the character is not decimal, it returns Nothing.

toBasicLatin '3'
--> Just '3'


toBasicLatin '٩'
--> Just '9'


toBasicLatin '🐐'
--> Nothing
normalize : String -> String

Extract only the decimal characters contained in a given string and convert them to the corresponding Basic Latin characters.

normalize "0123🐐45٩🌱"
--> "0123459"