Domanda

I have a little problem with german umlauts in my browser (firefox ~latest). German umlauts like ä,ö are shown as ä,ö. This Text comes from a utf-8 without bom formatted json file. If I have a look at the file on the server, the text is displayed correctly. This file get's loaded dynamicly by javascript:

$.getJSON(PATH_RELATIVE_JSON + fileName + '.json', function(data)
    {
        var json=data[Object.keys(data)[0]];

        if(!isEmpty(callBackName))
        {
            window[callBackName](json);
        }
    });

I also have extended the setup with: (prepended)

$.ajaxSetup({ scriptCharset: "utf-8" , contentType: "application/json; charset=utf-8"})

and also another $.ajax variant.

But the result looks not correct to me:

Accept-Ranges   bytes
Connection  close
Content-Length  581
Content-Type    text/plain; charset=iso-8859-1
Date    Tue, 26 Nov 2013 17:25:56 GMT
Etag    "91ce110-245-4ec0564348dc0"
Last-Modified   Mon, 25 Nov 2013 19:30:07 GMT
Server  Apache

Why is the Content-Type text/plain; charset=iso-8859-1? It should be UTF-8 and may everything would work right...

JSON: UTF-8 without BOM

Website: UTF-8 & in my file: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Javascript: UTF-8

always happy for any help!

È stato utile?

Soluzione

It's solved!!!!

someone gave me the tip to check my apache configuration.

Even with mod_rewrite rights you can change the default charset to UTF-8.

AddDefaultCharset UTF-8
AddCharset UTF-8 .js
AddCharset UTF-8 .css
AddCharset UTF-8 .php
AddCharset UTF-8 .json

That is my new Charset config.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top