Php with special characters like -

At first, I thought the problem was that I was returning echo json_encode ($ row) from the ajax call, the result of which was with a change to NULL. But after testing, I found out that the problem exists before that.

In an example php file with:

$test = "Nuñez" echo $test 

the result is Nu ez

I searched, but none of the proposed solutions work. How:

 mb_internal_encoding('UTF-8'); mb_http_output('UTF-8'); mb_http_input('UTF-8'); mb_language('uni'); mb_regex_encoding('UTF-8'); ob_start('mb_output_handler'); 

or <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> , or header('content-type: text/html; charset: utf-8'); . And a few more solutions that I already forgot, believe me, I tried a lot.

This is just the beginning of this, I hope this is not a problem with mysql, since my database is in utf-8, so this is my $ mysqli charset. But I think I can not say the same for ajax json_encode. But never mind, one problem at a time. Can someone please help me. Many thanks!

THE PROBLEM IS SOLVED I just needed to install "Encode to UTF-8" in Notepad ++, as before to "Encode to ANSI".

+6
source share
5 answers

for me

 $test = "Nuñez"; echo $test; 

Shows Nuñez

You may try

 $test = "Nuñez"; echo utf8_decode($test); 

or

 $test = utf8_encode("Nuñez"); echo utf8_decode($test); 
+5
source

try it

His work is for me.

 $test = "Nuñez"; echo html_entity_decode(htmlentities($test)); 
+2
source

to correctly display latin characters like ñ á é í ó ú, etc. in browsers, you should use iso-8859-1 instead of UTF-8 encoding http://www.w3schools.com/tags/ref_entities.asp

Best wishes!

+2
source

when you connect to your mysql db, set charset to utf-8, e.g. →

 $sql_con = mysql_connect($sql_host, $sql_user, $sql_pass); mysql_query('SET NAMES utf8'); 
+1
source

consider the default_charset setting, it worked for me

ini_set ('default_charset', 'utf-8');

0
source

All Articles