SQL query normalize accents, tilde

0

I often have to search for product names that have accents .. how to normalize this?

In my table I use collation utf8_general_ci, which is good for uppercase and lowercase (IC).

Now, accents, are being a problem, this collation already ignores something like, is from and to, from to, the problem is (ã- > till) with a, .. what to do?

    
asked by anonymous 11.06.2015 / 16:02

1 answer

1

Try to send a query

SET NAMES utf8;

Personally I solved the same problem by adding after the MySQL connection code :

mysql_set_charset("utf8");

or: mysqli_set_charset("utf8");

or the equivalent in OOP : $mysqli_link->set_charset("utf8");

And sometimes you will have to set the php main charset by adding this code: mb_internal_encoding('UTF-8');

On the HTML client side you have to add the following header data:

<meta http-equiv="Content-type" content="text/html;charset=utf-8" />

To use JSON AJAX results (for example, using jQuery), you must define the header by adding:

header("Content-type: application/json;charset=utf8");
json_encode(
     some_data
);

This should resolve

    
11.06.2015 / 16:13