haskell-servant / haskell-servant/servant

UTF-8 `É` incorrectly read as `Ã`

Open
#1,239 4 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
Haskell
Stars
2k
Forks
427
Avg merge
2d 23h
Merged PRs (30d)
5

Description

Hello, I've noticed that my Servant handler is incorrectly reading `É` as `Ã`. I've been able to isolate it to the handler, but no luck beyond that.

Mac: `macOS Mojave - Version 10.14.6`
Stack: `Version 2.1.3, Git revision 0fa51b9925decd937e4a993ad90cb686f88fa282 (7739 commits) x86_64 hpack-0.31.2`
GHC: `The Glorious Glasgow Haskell Compilation System, version 8.4.3`

#### When submitting the following request:

```
curl -i -X POST -H "Content-Type: text/plain; charset=utf-8" --data "{\"constraints\": [{\"column\": \"author\", \"values\": [\"CÉZANNE, Paul\"]}]}" http://localhost:8080/myEndpoint
```

#### ... To the following Servant handler:

```haskell
queryPaintings :: Pool Connection -> String -> Handler PaintingsResponse
queryPaintings conns constraintsInfo =
...
withResource conns $ \conn -> do
_ <- putStrLn $ "constraintsInfo: " ++ constraintsInfo
_ <- putStrLn "CÉZANNE, Paul"
...
```

#### ... Those `putStrLn` lines give:
```
constraintsInfo: {"constraints": [{"column": "author", "values": ["CÉZANNE, Paul"]}]}
CÉZANNE, Paul
```

#### Question:

Why, in the first line, do I have `CÃZANNE` instead of the desired `CÉZANNE`?

(I’ve alternatively tried having `curl` read a UTF-8 formatted text file — but same result.)

Many thanks in advance for your help.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.