Using of non latin characters in the Suave

时间:2017-06-15 09:29:04

标签: f# suave

I want to use non latin symbols in the Suave, for example, cyrillic, but getting the weird result

MCVE

open Suave
open Suave.Filters
open Suave.Operators
open Suave.Successful

let app =
    choose [
        GET >=>  OK "Привет, Мир!" 
    ]

startWebServer defaultConfig app

Result

enter image description here

So, the Q is - how to fix it?

2 个答案:

答案 0 :(得分:8)

For text only responses you need to set the mine type encoding: >=> setMimeType "text/plain; charset=utf-8"

Set the Content-Type header to the mime type given. Remember that it should include the encoding of your content. So for example, specifying a mimeType value of 'application/json; charset=utf-8' is strongly recommended (but replace 'json' with your own MIME type, of course ;))

答案 1 :(得分:4)

That looks like UTF-8 being interpreted as Latin-1. Try adding >=> setMimeType "text/html; charset=utf-8" to your app and see if that makes the browser treat your UTF-8 as actual UTF-8 instead of defaulting to the incorrect Latin-1.