Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using of non latin characters in the Suave

Tags:

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?

like image 237
FoggyFinder Avatar asked Dec 06 '25 18:12

FoggyFinder


2 Answers

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

like image 142
CaringDev Avatar answered Dec 09 '25 00:12

CaringDev


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.

like image 45
rmunn Avatar answered Dec 08 '25 23:12

rmunn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!