Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is WordPress doing for content encoding in its MySQL database?
    primarykey
    data
    text
    <p>For some convoluted reasons best left behind us, I require direct access the contents of a <a href="http://en.wikipedia.org/wiki/WordPress" rel="nofollow noreferrer">WordPress</a> database. I'm using <a href="http://en.wikipedia.org/wiki/MySQL" rel="nofollow noreferrer">MySQL</a> 5.0.70-r1 on <a href="http://en.wikipedia.org/wiki/Gentoo_Linux" rel="nofollow noreferrer">Gentoo</a> with WordPress 2.6, and Perl 5.8.8 ftr.</p> <p>So, sometimes we get high-order characters in the blog, we have quite a few authors contributing too, for the most part these characters end up in WordPress's database in <code>wp_posts.post_content</code> or <code>wp_postmeta.meta_value</code>, Wordpress is displaying these correctly on its site, but the database stores it using single byte encoding that I can't figure out how to convert to the correct string. Today's example: </p> <p>The blog shows this, and doesn't even seem to escape any chars in the HTML,</p> <pre><code> Hãhãhães </code></pre> <p>but the database, when viewed via the MySQL prompt, has,</p> <pre><code> Hãhãhães </code></pre> <p>So clearly this is some kind of double-byte encoding issue, but I don't know how I can correct it. I need to be able to pull that second string from the database (because that's what it gives me) and convert it to the first one, and I need to do so using Perl.</p> <p>Also, just to help unmuddy any waters, I took these strings and printed out the ASCII codes for each character using Perl's <code>ord()</code> function.</p> <p>Here is the output of the "wrong" string:</p> <pre><code>H = 72 à = 195 £ = 163 h = 104 à = 195 £ = 163 h = 104 à = 195 £ = 163 e = 101 s = 115 </code></pre> <p>This is the correct string, that I need to produce in my script:</p> <pre><code>H = 72 ã = 227 h = 104 ã = 227 h = 104 ã = 227 e = 101 s = 115 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload