UTF-8 encoding problem in Spring MVC

I’ve figured it out, you can add to request mapping produces = “text/plain;charset=UTF-8” @RequestMapping(value = “/rest/create/document”, produces = “text/plain;charset=UTF-8”) @ResponseBody public void create(Document document, HttpServletRespone respone) throws UnsupportedEncodingException { Document newDocument = DocumentService.create(Document); return jsonSerializer.serialize(newDocument); } see this blog post for more details on the solution

How to download any(!) webpage with correct charset in python?

When you download a file with urllib or urllib2, you can find out whether a charset header was transmitted: fp = urllib2.urlopen(request) charset = fp.headers.getparam(‘charset’) You can use BeautifulSoup to locate a meta element in the HTML: soup = BeatifulSoup.BeautifulSoup(data) meta = soup.findAll(‘meta’, {‘http-equiv’:lambda v:v.lower()==’content-type’}) If neither is available, browsers typically fall back to user … Read more

git log output encoding issues on Windows 10 CLI terminal

Okay, I experimented a bit and found out that Windows Git commands actually need UNIX variables like LC_ALL in order to display Polish (or other UTF-8 characters) correctly. Just try this command: set LC_ALL=C.UTF-8 Then enjoy the result. Here is what happened on my console (font “Consolas”, no chcp necessary): Update: Well, in order for … Read more

ISO-8859-1 encoding and binary data preservation

“\u00F6” is not a byte array. It’s a string containing a single char. Execute the following test instead: public static void main(String[] args) throws Exception { byte[] b = new byte[] {(byte) 0x00, (byte) 0xf6}; String s = new String(b, “ISO-8859-1”); // decoding byte[] b2 = s.getBytes(“ISO-8859-1”); // encoding System.out.println(“Are the bytes equal : ” … Read more

Jquery ignores encoding ISO-8859-1

Because I had the same problem, I’ll provide a solution that worked for me. Background: Microsoft Excel is too stupid to export a CSV-File in charset UTF-8: $.ajax({ url: ‘…’, contentType: ‘Content-type: text/plain; charset=iso-8859-1’, // This is the imporant part!!! beforeSend: function(jqXHR) { jqXHR.overrideMimeType(‘text/html;charset=iso-8859-1’); } });

dompdf character encoding UTF-8

You should read over the Unicode How-to again. The main problem is that you don’t specify a font that supports your characters. It looks like you’ve read the how-to, because you’re using the font example from that document. However the example was not meant to apply globally to any document, dompdf doesn’t include firefly (a … Read more