2

Spanish special characters are not displaying correctly, a word like: 'Árbol' is displayed like '�bol'.

1) Text in database is saved correctly. 'Árbol' looks perfect on database.

2) If I insert a new word, eg. 'Tétrico', it is saved correctly on database.

I've been experiencing this problem since I moved the project to another server, on localhost (Ubuntu server) works perfect.

I've tried everything reading similar questions:

  • View files are encoded in UTF-8 without BOM.
  • header('Content-type: text/html; charset=utf-8');
  • In my.cnf, I've added the lines:

    init_connect='SET NAMES utf8'

    character_set_server=utf8

It just doesn't work.

What else can I do?

I've replicated changes that I did on localhost (because project works perfect here, everything's displaying correctly) to new server, but nothing's changed.

Francisco Ochoa
  • 1,538
  • 4
  • 19
  • 43
  • The data you're outputting is not actually UTF-8 encoded. I'd be guessing the Codeigniter database configuration is not set to utf8. – deceze Nov 04 '13 at 15:48
  • decese, it is: on config.php $config['charset'] = 'UTF-8'; and in database.php $db['default']['char_set'] = 'utf8'; $db['default']['dbcollat'] = 'utf8_unicode_ci'; – Francisco Ochoa Nov 04 '13 at 15:49

1 Answers1

6

I'm not exactly sure why, but I had this on html views and it wasn't working.

header('Content-Type: text/html; charset=utf-8');

By reading this post, I found an alternative answer:

How to display special characters in PHP

So I had to change the header of html files. I put this line:

header('Content-Type: text/html; charset=ISO-8859-1');

and it works perfect now.

Community
  • 1
  • 1
Francisco Ochoa
  • 1,538
  • 4
  • 19
  • 43