Why doesn't the database result show accents?

I am migrating a project from CMS called "Freekore" to CodeIgniter, with my old CMS I didn't have this problem, but with CI I can't figure out why I have problems with special characters like ñ,á,é,í

etc. I seem to have tried everything.
I got this in the title

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

      

also added this

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

      

in the database configuration

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

      

and in the config file

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

      

But I still get this

COMUNICACIÃ"N Y PRODUCCIÃ"N EDITORIAL

      

instead of this

COMUNICACIÓN Y PRODUCCIÓN EDITORIAL

      

ah and also added to .htaccess

AddDefaultCharset UTF-8

      

Edit
Using this I found out what the current character set is latin1

, but how? I checked the database and tables andutf8_general_ci

Edit 2
I made a new database and checked every column collation, now I am using utf8_unicode_ci

in the database, in every table and in every row, but I still have the same problem Current character setlatin1

Edit 3
I decided to use utf8_decode

and it seemed to work, but I still have problems with the tops

+3


source to share


6 answers


After hours of searching for something that helped me fix the problem, I found the answer so easy in this post , so I used this one before doing input mysql_query("SET NAMES utf8");

and now the characters are displayed as they should. Thank you so much for your help.



+1


source


Have you tried to encode your data in UTF-8 before putting it into your new db using this function: http://www.w3schools.com/php/func_xml_utf8_encode.asp p>



+1


source


Database table comparison is not UTF-8 unicode. Look here for example in phpmyadmin:

enter image description here

You need to update the mapping. If you don't have phpmyadmin, you can use the following command:

ALTER TABLE `test_table` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

      

0


source


I think you need to change your database collection to UTF 8
do the following queries.

ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

      

hope it solves your problem.

0


source


Your problem is probably related to utf8_general_ci

(MySQL 5.x by default) as your collation. Most people are surprised that not all UTF8s are the same. For the most part, you have 3 common "flavors"

  • utf8_general_ci
  • utf8_unicode_ci
  • utf8mb4

The difference is in how many bytes are used for UTF8. utf8mb4

is the full UTF8 character set, and utf8_general_ci

is a small subset that covers most of the latin character sets but probably does not cover the characters you mentioned. If you go to utf8_unicode_ci

, it might close them. The catch is that the more bytes you use, the slower your database will be when processing this data.

This section discusses this in more detail. What is the difference between utf8_general_ci and utf8_unicode_ci

0


source


Echo utf8_encode ($ row ['$ your_field']);

0


source







All Articles