Seems like some of my text got lost..
I had to write the following to get DataTables to even fetch columns containing æøå:
function encode_items(&$item, $key) {
$item = utf8_encode($item);
}
array_walk_recursive($output, 'encode_items');
echo json_encode( $output );
My other problem now, is that I can't filter according to æøå.
As soon as I write æø or å, it tells me nothing can be found.
Database is UTF-8, all files is UTF-8.
Yes. I set both the file encoding, and the meta tag in all my files. As I said, I got it working with fetching by using UTF8_encode. But I can't get filtering to work..
The database is UTF-8, and the chars are stored as æø and å.
I think its due to DataTables encoding the filter-input or something.
Im not that experienced with this, which is why I am asking for help.
DataTables doesn't do any character conversation at all and will work with whatever strings you give it. Can you give us a link please so I can see it in action?
You are using server-side processing, so the filtering is done entirely on the server-side. This is the search parameter which is being sent when searching for "ø":
> sSearch=%C3%B8
So the first thing I would suggest is echoing out $_POST['sSearch'] in the 'search.php' script and make sure that it is decoded as "ø" by the server-side. If it is, then I would next suggest echoing out the SQL that is run against the server and try running it through something like phpMyAdmin or whatever. If not, then the question is, why isn't PHP decoding a UTF8 character and what is it decoding it as...
Replies
I had to write the following to get DataTables to even fetch columns containing æøå:
function encode_items(&$item, $key) {
$item = utf8_encode($item);
}
array_walk_recursive($output, 'encode_items');
echo json_encode( $output );
My other problem now, is that I can't filter according to æøå.
As soon as I write æø or å, it tells me nothing can be found.
Database is UTF-8, all files is UTF-8.
Allan
I think its due to DataTables encoding the filter-input or something.
Im not that experienced with this, which is why I am asking for help.
Allan
"bServerSide": true,
"sAjaxSource": "search.php"
[/code]
You are using server-side processing, so the filtering is done entirely on the server-side. This is the search parameter which is being sent when searching for "ø":
> sSearch=%C3%B8
So the first thing I would suggest is echoing out $_POST['sSearch'] in the 'search.php' script and make sure that it is decoded as "ø" by the server-side. If it is, then I would next suggest echoing out the SQL that is run against the server and try running it through something like phpMyAdmin or whatever. If not, then the question is, why isn't PHP decoding a UTF8 character and what is it decoding it as...
Allan
Ill take a look at it now.
To the PHP script.
Thanks for the quick responses and your help.
Regards,
Allan