funny, I was looking into this yesterday!
I am by no means an expert, but I think that what it is happening is the 
following: 
application/json implies UTF-8: if you look at the MediaType class from 
akka http you se the declaration:

val `application/json` = awfc("json", HttpCharsets.`UTF-8`, "json")



second,  get the data from your service with curl/wget and have a look. 
When I did in my experiment the data in the file was correctly rendered as 
UTF-8. 

now, why non-ascii characters are messed up when you look at it in the 
browser? I think that the browser is trying to render json as HTML, and 
since the data is not html it defaults to HTML default encoding, which is 
ISO-8859-1 (https://www.w3schools.com/html/html_charset.asp), so it renders 
your data incorrectly.

In conclusion I believe that is not akka http at fault, but the default 
behavior of all web browser (I saw it on chrome and safari): your data is 
fine, it is just displayed wrongly when you look at it in a browser

Alex




On Friday, May 5, 2017 at 12:40:30 AM UTC-7, Thibault Meyer wrote:
>
> Hello,
>
> I dont find how to set the content type to "*application/json; 
> charset=UTF-8*" with the *completeOKWithFuture* and Jackson marshaller. 
> Currently, Akka Http return the Content-Type "application/json" without 
> specifying the charset. So in some browsers (like Opera or Chrome) the 
> output text is not good.
>
>
> get(() -> {
>   final MessageDispatcher dispatcher = akkaSystem.dispatchers().lookup(
> "application.dispatcher");
>   return completeOKWithFuture(CompletableFuture.supplyAsync(() -> {
>     final Map<String, Object> result = new HashMap<>();
>     result.put("trackingNumber", trackingNumber);
>     ArrayList<Map<String, String>> status;
>     if (this.cache == null) {
>       status = TrackingCrawler.parseDocument(trackingNumber);
>     } else {
>       status = this.cache.readFromCache("tracking." + trackingNumber);
>       if (status == null) {
>         status = TrackingCrawler.parseDocument(trackingNumber);
>         this.cache.writeToCache(
>           "tracking." + trackingNumber,
>           status
>         );
>       }
>     }
>     result.put("status", status);
>     return result;
>   }, dispatcher).exceptionally(ex -> {
>     LOG.error("Something goes wrong", ex);
>     return new HashMap<>();
>   }), Jackson.marshaller());
> })
>
>
>
> Sincerly.
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to