jcharToChar :: JChar -> Maybe Char
jcharToChar jchr
  | not isSurrogate = Just $ chr jchrVal
  | otherwise = Nothing
  where jchrVal = fromIntegral jchr
        -- check if JChar is reserved UTF-16 value - not a valid character
        isSurrogate = 0xD800 <= jchrVal && jchrVal <= 0xDFFF
jcharToChar :: JChar -> Maybe Char
jcharToChar jchr
  | not isSurrogate = Just $ chr jchrVal
  | otherwise = Nothing
  where jchrVal = fromIntegral jchr
        -- check if JChar is reserved UTF-16 value - not a valid character
        isSurrogate = 0xD800 <= jchrVal && jchrVal <= 0xDFFF
jcharToChar jchr
  | not isSurrogate = Just $ chr jchrVal
  | otherwise = Nothing
  where jchrVal = fromIntegral jchr
        -- check if JChar is reserved UTF-16 value - not a valid character
        isSurrogate = 0xD800 <= jchrVal && jchrVal <= 0xDFFF