We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7eac69e commit cde0d26Copy full SHA for cde0d26
src/Data/String/CodePoints.purs
@@ -77,11 +77,13 @@ foreign import _unsafeCodePointAt0
77
-> CodePoint
78
79
unsafeCodePointAt0Fallback :: String -> CodePoint
80
-unsafeCodePointAt0Fallback s | String.length s == 1 = CodePoint (Unsafe.charCodeAt 0 s)
81
-unsafeCodePointAt0Fallback s = CodePoint (unsurrogate lead trail)
+unsafeCodePointAt0Fallback s =
+ if isLead cu0 && isTrail cu1
82
+ then unsurrogate cu0 cu1
83
+ else CodePoint cu0
84
where
- lead = Unsafe.charCodeAt 0 s
- trail = Unsafe.charCodeAt 1 s
85
+ cu0 = Unsafe.charCodeAt 0 s
86
+ cu1 = Unsafe.charCodeAt 1 s
87
88
89
codePointAt :: Int -> String -> Maybe CodePoint
0 commit comments