Search code examples
f#suave

Using of non latin characters in the 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?


Solution

  • 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 ;))