简体   繁体   中英

php mysql codeigniter character encoding

Iam using codeIgniter and having the following settings but still my webpage is displaying "?" in case of special characters.

Database - UTF-8 encoding Table - UTF-8 column -UTF-8 in the html file I have the following line added

<? header("Content-Type: text/html; charset=UTF-8"); ?>

37 degrees centigrade is displayed as "maintained at 37 C"

and other special characters are also wrongly displayed.

Set this

In config.php

$config['charset'] = "UTF-8";

In database connection

$db['default']['char_set'] = "utf8"; 
$db['default']['dbcollat'] = "utf8_unicode_ci";

In Header of your file

echo meta('Content-type', 'text/html; charset=utf-8', 'equiv');
// Generates:  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />

Adding

<?php header('Content-type: text/html; charset=iso-8859-1'); ?>

to my html header worked for me!!!!

Please try with utf8_general_ci collation.

$db['default']['dbcollat'] = "utf8_general_ci";

If still your problem is not resolved, then set column collation as utf8_general_ci in your database table.

This will work.

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM