File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
System/Console/Haskeline/Backend Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -72,11 +72,17 @@ eventReader h = do
7272 es <- readEvents h
7373 return $ combineSurrogatePairs $ mapMaybe processEvent es
7474
75+ isSurrogatePair :: Char -> Char -> Maybe Char
76+ isSurrogatePair c1 c2
77+ | 0xD800 <= ord c1 && ord c1 < 0xDC00 && 0xDC00 <= ord c2 && ord c2 < 0xE000
78+ = Just $ (((ord c1 .&. 0x3FF ) `shiftL` 10 ) .|. (ord c2 .&. 0x3FF )) + 0x10000
79+ | otherwise
80+ = Nothing
81+
7582combineSurrogatePairs :: [Event ] -> [Event ]
7683combineSurrogatePairs (KeyInput [Key m1 (KeyChar c1)] : KeyInput [Key _ (KeyChar c2)] : es)
77- | 0xD800 <= ord c1 && ord c1 < 0xDC00 && 0xDC00 <= ord c2 && ord c2 < 0xE000
78- = let c = (((ord c1 .&. 0x3FF ) `shiftL` 10 ) .|. (ord c2 .&. 0x3FF )) + 0x10000
79- in KeyInput [Key m1 (KeyChar (chr c))] : combineSurrogatePairs es
84+ | Just c <- isSurrogatePair c1 c2
85+ = KeyInput [Key m1 (KeyChar (chr c))] : combineSurrogatePairs es
8086combineSurrogatePairs (e: es) = e : combineSurrogatePairs es
8187combineSurrogatePairs [] = []
8288
You can’t perform that action at this time.
0 commit comments