AntonioCS
AntonioCS

Reputation: 8496

Change the characters in mysql with Convert failing - Still getting Não

I am populating this mysql table with data from a php (via post and using filter_input). The database is utf8 but when I have a user that inputs words with ^,',',~ like Não I get this -> Não

What do I have to do to make it show the correct values. Or should I try to make some correction when I retrieve the data??

UPDATE:

I have added a utf8_decode and now it is inserting ok. Anyone know how to convert the string that were already in the table?? I tried using the convert function but I can't make it work :(

UPDATE:

I am trying this code:

select convert(field using latin1) from table where id = 35;

And I am still getting this: Não I tried other encoding s but I never get the word Não

Anyone have any thoughts on this one??

Upvotes: 0

Views: 218

Answers (2)

Yuliy
Yuliy

Reputation: 17718

It looks like somewhere along the way something cannot handle Unicode. As a result, ã is getting interpreted as two separate characters. Make sure everything that handles strings is OK with Unicode.

Upvotes: 0

RVeur23
RVeur23

Reputation: 81

First, make sure your page is utf-8

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

next, if your on Apache, make sur your in UTF-8 in config file :

AddDefaultCharset UTF-8

or your can do it in a .php file like this :

header('Content-type: text/html; charset=UTF-8'); 

if you still have problem, you can use the encode function :

$value = utf8_encode($value);

Hope all this will help...

Upvotes: 1

Related Questions