标签云

微信群

扫码加入我们

WeChat QR Code

I need some help in an issue I am having with spanish special characters. A brief summary of what I am doing first. I have written a PHP script which fetches data from Google Spreadsheet using Zend Google PHP API. This data is then put into MySql database.$row=$Col->getText(); //getText is the Google API that returns the value in the row.print "$row"; // I print the contentBut the issue is that some spanish characters such as ñer appear as ñer. Later on in the PHP code I go on to save these values in MySql. And even in the tables the same issue.Don't know where the issue is.I tried various different things such as edit the PHP ini file and add:mbstring.language = Neutral ; Set default language to Neutral(UTF-8) (default)mbstring.internal_encoding= UTF-8 ; Set default internal encoding to UTF-8mbstring.encoding_translation = On;HTTP input encoding translation is enabledmbstring.http_input = auto; Set HTTP input character set dectection to autombstring.http_output= UTF-8 ; Set HTTP output encoding to UTF-8mbstring.detect_order = auto; Set default character encoding detection order to autombstring.substitute_character = none; Do not print invalid charactersdefault_charset = UTF-8 ; Default character set for auto content type headermbstring.func_overload= 7 ; All non-multibyte-safe functions are overloaded with the mbstring alternativesAdd in the below in MySqlinit_connect='SET collation_connection = utf8_unicode_ci; SET NAMES utf8;'character-set-server=utf8collation-server=utf8_unicode_ciskip-character-set-client-handshakeChange Database and Table propertiesALTER DATABASE db_nameCHARACTER SET utf8DEFAULT CHARACTER SET utf8COLLATE utf8_general_ciDEFAULT COLLATE utf8_general_ci; ALTER TABLE tbl_nameDEFAULT CHARACTER SET utf8COLLATE utf8_general_ci;Call SETNAMES etc just after mysql open connection.$q="SET NAMES 'utf8'";$r=mysql_query($q);mysql_query("SET CHARACTER SET utf8");But nothing seems to work. Please help


Please use SO's search.stackoverflow.com/questions/9174881/…

2019年04月20日25分43秒

It makes no sense to blindly throw encoding configuration settings onto something if you have no clue in which encoding actually the data was retrieved and stored. UTF-8 does not solve all encoding problems magically.

2019年04月19日25分43秒

hakre: - I am no expert when it comes to encoding. That's why I am asking for opinions from others like you. We for starters I am not sure where things are going bad. In the sense are things going bad when ZEND GDATA returns the row name? Or does it go bad when MySql gets into the picture. Any suggestions to debug this issue will be very welcome. All of my application works, just this encoding problem is killing me.

2019年04月20日25分43秒

Alfabravo: - Thanks for your suggestion. I did search a lot and am still searching for the answer to my issue. Nothing is working as of now. And to add to my vows, I am not very experienced with encoding and all.

2019年04月20日25分43秒

The thread i referenced shows how to set connection encoding correctly. Also, if you have already inserted data in a wrong encoding, doesn't matter you change table encoding, the bad data stills!

2019年04月19日25分43秒

Hi, Thanks for your reply. Well I am not running the script was the browser. It's run from command line. And yes I corrected the query to $q="SET NAMES utf8"; Still does not work.

2019年04月19日25分43秒

Is the result of $Col->getText(); actually utf8?

2019年04月20日25分43秒

Thats what I don't know. PLease let me know how I can find that out. Because when I print the output on the screen then it shows the weird characters. I don't know if that's a linux issue in displaying special characters or if the variable itself i use to store $Col->getText(); has some other encoding other than utf-8. Dunno if I am making sense here.

2019年04月20日25分43秒