Add a test for a very simple CSV encoding
This commit is contained in:
parent
459c48a2d9
commit
cd3631e5fd
6 changed files with 82 additions and 3 deletions
|
@ -403,7 +403,7 @@ word8PaddedUpperHex w =
|
|||
-- | Encode an ASCII char.
|
||||
-- Precondition: Input must be an ASCII character. This is not checked.
|
||||
ascii :: Char -> Builder
|
||||
ascii c = fromBounded Nat.constant (Bounded.char c)
|
||||
ascii c = fromBounded Nat.constant (Bounded.ascii c)
|
||||
|
||||
-- | Encode an UTF8 char. This only uses as much space as is required.
|
||||
char :: Char -> Builder
|
||||
|
|
|
@ -507,10 +507,12 @@ word8LowerHex# w#
|
|||
where
|
||||
w = W# w#
|
||||
|
||||
-- | Encode an ASCII char.
|
||||
-- | Encode an ASCII character.
|
||||
-- Precondition: Input must be an ASCII character. This is not checked.
|
||||
ascii :: Char -> Builder 1
|
||||
ascii c = word8 (fromIntegral @Int @Word8 (ord c))
|
||||
ascii (C# c) = Unsafe.construct $ \(MutableByteArray arr) (I# off) -> do
|
||||
primitive_ (writeCharArray# arr off c)
|
||||
pure (I# (off +# 1# ))
|
||||
|
||||
-- | Encode a character as UTF-8. This only uses as much space as is required.
|
||||
char :: Char -> Builder 4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue