0

I hate characters sets and everything related, they make me get headaches!!

I'm now working on an app for using with OpenCart. The database is coded with utf8-bin.

What I want to do with my app in PHP is take data from an XML (encoded in ISO-8859-1) and put it correctly on the DB (encoded in UTF8-BIN)

I tried using $msqli->set_charset("utf8"); when connecting, utf8_encode with the strings, but nothing, it still shows strange characters.

Thanks in advance

3
  • where does it show strange characters ? phpMyAdmin ? opencart pages ? Commented May 25, 2012 at 12:30
  • Have you tried running the XML data through php.net/manual/en/function.utf8-encode.php ? Commented May 25, 2012 at 12:41
  • Justin: Both in phpMyAdmin and pages in Opencart. If I encode strings with utf8_encode, in phpMyAdmin is shown a number (an hex number, I think) Hammerite: I tried it with and without utf8_encodue Commented May 25, 2012 at 12:42

3 Answers 3

3

You need to use UTF8 the whole way. You are right about connecting to MySQL with UFT8, but you must also convert the file after reading it, and make sure you have UTF8 specified in the HTML page, in the header with <meta http-equiv="content-type" content="text/html;charset=utf-8" />, or in the HTTP header. Otherwise you need to convert to whatever charset you use on the page before printing the strings.

My advice is to use UTF8 everywhere. Then you'll avoid a lot of the problems.

Sign up to request clarification or add additional context in comments.

1 Comment

As Opencart is a CMS, it should be balanced between its MySQL and its pages. It shows this on the pages: <?xml version="1.0" encoding="UTF-8"?>. Is this enough, or should I force to show "meta..."? Thanks
0

You have to convert the XML from ISO to UTF before you put it into the DB! Check this

http://www.unicodetools.com/

Comments

0

Strangely, after a lot of tries, what it made codification work was "utf8_decode". I don't know exactly what the problem was, but now is solved!

Thanks for your answers!!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.