Stackfull
Stackfull

Reputation: 103

UTF-8 is encoding not working in PHP

8 encoding is not working when i am fetching data from mysql table i have some special characters in database unable to fetch some cities with special characters like Østfold city and Ærø so when i type ostfold its not fetching Østfold city from database. while i am perfectly getting Šiauliai and Çorum from db when i write sia and cor respectively.

I have a city table i am getting cities from this table using jquery autocomplete ajax so when I type first three letters it shows me list of related letters I am working in CodeIgniter framwork.

my settings of CodeIgniter database.php :-

$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';

My database table city's column setting is :-

city_name(column name)  varchar(100)    utf8_general_ci(Collation)

Please help me anything else i have to change for this why i am unable to get cities starting with this characters like Ø and Æ.

Upvotes: 0

Views: 202

Answers (3)

Ravi Sharma
Ravi Sharma

Reputation: 487

try this code i hope this will resolved your problem.

file_exists(mb_convert_encoding("file_å.txt", "UTF-8"));

Upvotes: 2

Rick James
Rick James

Reputation: 142208

See Reference

Ø = O for only one collation: utf8_unicode_520_ci; most treat it like a letter between O and P. A few collate it after Z.

Æ is a different matter. It collates the same as the two letters AE in utf8_unicode_520_ci and at least one other collation. Otherwise it is between A and B or after Z.

Ç is yet another matter. It is equal to C for all collations except utf8_turkish_ci, in which case it is a letter between C and D.

Š = S for many collations; between S and T for some.

Bottom line: Use utf8_unicode_520_ci for the column and the connection; type Æ as AE.

Upvotes: 0

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324610

The collation table does not list Æ to be equal to A, neither does it list Ø to be equal to O.

You don't have an encoding problem (otherwise Çorum = corum wouldn't work), but instead an expectations problem. You expected them to be equal. By the definition of the collation table, they aren't.

Upvotes: 0

Related Questions