Welcome Guest, Not a member yet? Register   Sign In
Problem with DB encoding.....
#1

[eluser]louis w[/eluser]
I am trying to update a field in the db with an xml string but it's getting very garbled with the db encoding. As a safety measure I did not want to turn it off thou.

My application does a pass over the xml value to encode certain characters such as "smart" curly quotes into their encoded value. (e.g. ‘ )

If all i try to update is a right curly quote, the final query to the db is:
<description>&lt;![CDATA[<p>&#xC3;&#xA2;&#xC2;&#x20AC;&#xC2;&#x153;</p>]]></description>

What's with ALL THE CRAZY stuff in there? It's causing a big headache.

I would like for it to remain as a html encoded entity string like &amp;#8216;
#2

[eluser]louis w[/eluser]
Update:

I found the ascii_to_entities function in the text helpers which seems to be doing almost what i was already. But still when the value goes through the db escape it's getting messy.

é
after ascii_to_entities and db escape becomes
&#xC3;&#xA9;
#3

[eluser]fensen[/eluser]
Have you tried converting the string from/to multi byte

This converts Japanese SHIFT-JIS to UTF-8
$a = mb_convert_encoding($txt, "UTF-8", "SJIS");

your string doesn't look like SHIFT-JIS, so maybe you should try other encodings (have a look at the manual).

By the way, do you know if your XML string may be Japanese, Korean, or any other language?




Theme © iAndrew 2016 - Forum software by © MyBB