Search with utf8 characters in server side datatables with JSON-MySQL data source

Search with utf8 characters in server side datatables with JSON-MySQL data source

AlejandroQAlejandroQ Posts: 1Questions: 0Answers: 0
edited June 2013 in Blog
Hi.

I hope this help someone.

The environment:
- Files encoded with utf-8. IDE, editors configured to save/edit files with utf8 as default
- MySQL database created with utf-8 encoding, collation, conections.
- Table fields with utf8 encoding (char, varchar, text fields)
- Apache web server on Linux with utf8 encoding (.htaccess)
- Meta tags in views / pages with utf-8 meta
- Datatables plugin version 1.8.1

As you can see, all is in utf8 encoding for correct display / save data with this encoding.

When you provide server side data in JSON format with PHP to dataTables plugin, function json_encode($response), PHP =, in json_encode function, you can choose or skip this default function output. But in my case, production servers are with PHP 5.3.

This isn´t datatable error / bug; you need to clean your results before send to datatables when use json_encode with PHP 5.3
This discussion has been closed.