File tree 1 file changed +9
-3
lines changed
System/Console/Haskeline/Backend
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -72,11 +72,17 @@ eventReader h = do
72
72
es <- readEvents h
73
73
return $ combineSurrogatePairs $ mapMaybe processEvent es
74
74
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
+
75
82
combineSurrogatePairs :: [Event ] -> [Event ]
76
83
combineSurrogatePairs (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
80
86
combineSurrogatePairs (e: es) = e : combineSurrogatePairs es
81
87
combineSurrogatePairs [] = []
82
88
You can’t perform that action at this time.
0 commit comments