Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Char.isLower and Char.isUpper Unicode-aware #970

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions src/Char.elm
Original file line number Diff line number Diff line change
Expand Up @@ -66,46 +66,42 @@ type Char = Char -- NOTE: The compiler provides the real implementation.
-- CLASSIFICATION


{-| Detect upper case ASCII characters.
{-| Detect upper case Unicode characters.

isUpper 'A' == True
isUpper 'B' == True
...
isUpper 'Z' == True

isUpper 'Σ' == True

isUpper '0' == False
isUpper 'a' == False
isUpper '-' == False
isUpper 'Σ' == False
-}
isUpper : Char -> Bool
isUpper char =
let
code =
toCode char
in
code <= 0x5A && 0x41 <= code
(char == Char.toUpper char)
&& (char /= Char.toLower char)


{-| Detect lower case ASCII characters.
{-| Detect lower case Unicode characters.

isLower 'a' == True
isLower 'b' == True
...
isLower 'z' == True

isLower 'π' == True

isLower '0' == False
isLower 'A' == False
isLower '-' == False
isLower 'π' == False
-}
isLower : Char -> Bool
isLower char =
let
code =
toCode char
in
0x61 <= code && code <= 0x7A
(char == Char.toLower char)
&& (char /= Char.toUpper char)


{-| Detect upper case and lower case ASCII characters.
Expand Down