1

I have text coming from a SOAP service that i need to input into my mysql DB

text comes from SOAP in UTF-8 and MySQL tables are set to latin1_swedish_ci

I found how to fix the problem on my old server, we just moved to a new server and script are not working any more

My test string is this "abc €ùÁÄÅ def ‘O’"

If i don't change the string i just update the database the fist part "€ùÁÄÅ" don't have issue but the second mess up into "âOâ"

if i use

$mySql = iconv("UTF-8", "ISO-8859-1//IGNORE", $mySql);

i lose "€ùÁÄÅ" and "‘O’" part of the string

if i use

$mySql = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $mySql);

this is what i was using on old server, but on new server I lose the all string $mySql is empty

if i use

$mySql = utf8_decode($mySql);

i get question marks "abc ????? def ?O?"

al404IT
  • 1,380
  • 3
  • 21
  • 54
  • Silly question but why do you have to use latin1_swedish_ci for your database, why not use utf8 for the db as well? (utf8mb4 if you can) – Ben Apr 01 '17 at 09:21
  • because is old website and needs to migrate to utf-8 but, i was hoping later on – al404IT Apr 01 '17 at 09:45
  • 1
    ISO-8859-1 cannot represent everything that UTF-8 can, so converting to it will be a lossy operation. The right answer it to use [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through). – user3942918 Apr 01 '17 at 15:15
  • Do not use any conversion functions; go UTF-8 all the way. – Rick James Apr 01 '17 at 19:16

0 Answers0