Does DataTables support UTF8?
Does DataTables support UTF8?
Hello,
I reviewed all discussions related to UTF8 issues, but most of them point to setting proper encoding to database. In my case UTF8 symbols are properly written to database (example: 'Des3ąčęėįšųūž'), but the issue is displaying them.
Manually created json response which contains utf symbols, but they are displayed as 'Des3s?ra?as'
Below is json string I tried:
"{\"data\":[{\"DT_RowId\":2,\"name\":\"tests2\",\"description\":\"1234\"},{\"DT_RowId\":3,\"name\":\"tests3\",\"description\":\"Des3s\u0105ra\u0161as\"}]}"
I also tried to enter utf symbols in examples provided on this site(datatables.net), but they are being replaced to '?' symbol then return back from edit form.
This question has an accepted answers - jump to answer
Answers
Yes, DataTables support supports UTF8. In fact it doesn't actually do any character set handling of its own, so whatever the page is encoded in it will use that. The database and the page itself at the two main points to check.
In the Editor examples?
Allan
Lets take this datatables example:
http://editor.datatables.net/examples/advanced/REST.html
I choose to edit first record and modify Name to 'Airiąčęė', after update it is displayed as 'Airi???? Satou'. I checked page encoding and i see '<meta http-equiv="Content-type" content="text/html; charset=us-ascii">'.
In my test environment encoding is UTF-8:
<meta charset="utf-8">
But the result seems to be the same, so it made me to hesitate about UTF-8 support.
Thank you for pointing that out - it will work correctly now. It was a misconfiguration between by database and PHP!
Regards,
Allan
Found out that in my case the problem was missing characterEncoding, which tells how to read files from disk:
Also it seems that data passed to the table has to be transformed to Unicode format '\u0105' as this is a limitation of Spring+Thymeleaf.
Thanks for posting back an update for this - I'd never of found that out!
Allan