Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

After upgrading from 2.8.x (maybe it was 2.9.x) to 3.1.2, all the references inside posts to filenames (usually images) which contain accented chars stopped working.

Before, filenames that are displayed in the filesystem like "EXPRESSÃO.jpg" would be correctly called out in the post content HTML as "EXPRESSÃO.jpg". WP 3.x decided to convert those references to "EXPRESSÃO.jpg" (which is what the filename looked like when created/uploaded by the blog author), so now all the images that have such chars are broken links.

ONLY references to filenames are mangled. All other accented text works fine. i was able to, with the help of a perl script via SSH, obtain a list of all the files that have special chars.

Tabel with all the mangled chars: http://pastebin.com/MMbjJphU (BTW which table is this?)

wp-config shows (yes i already tried to comment them out)

define('DB_CHARSET', '');
define('DB_COLLATE', '');

mySQL shows:

DB Collation in effect: latin1_swedish_ci    
default DB Collation: latin1_swedish_ci    
Tables Collation: latin1_swedish_ci    
Columns Collation: latin1_swedish_ci

whats the quickest way to solve this problem? from what i see, i have 2 options:

A) i could rename the files to use the correct spelling (EXPRESSÃO.jpg -> EXPRESSÃO.jpg). I am leaning towards this. Maybe someone could help with a php/perl/python script that would rename the files?

B) i could batch update wp-posts in phpmyadmin to start using all those weird chars (EXPRESSÃO.jpg -> EXPRESSÃO.jpg).

share|improve this question
    
this question will likely be answered here –  Gaia May 4 '11 at 2:52
    
thanks for the grammEr edits, @Chris_O! –  Gaia May 4 '11 at 15:31
    
Possible Duplicate: wordpress.stackexchange.com/questions/7092/… –  chrisjlee May 31 '11 at 16:48
add comment

2 Answers

Maybe you should consider option C).
Convert all accented characters to normal UTF-8 characters.
So EXPRESSÃO.jpg -> EXPRESSAO.jpg

I think this would help you a lot, not only when it come sto coding and file systems, but also storing names / references in databases.

Update

This is a function I use for removing accents. I found this solution somewhere on the web.

  function sanitizeName($name)
  {
      $pattern = array("'é'", "'è'", "'ë'", "'ê'", "'É'", "'È'", "'Ë'", "'Ê'", "'á'", "'à'", "'ä'", "'â'", "'å'", "'Á'", "'À'", "'Ä'", "'Â'", "'Å'", "'ó'", "'ò'", "'ö'", "'ô'", "'Ó'", "'Ò'", "'Ö'", "'Ô'", "'í'", "'ì'", "'ï'", "'î'", "'Í'", "'Ì'", "'Ï'", "'Î'", "'ú'", "'ù'", "'ü'", "'û'", "'Ú'", "'Ù'", "'Ü'", "'Û'", "'ý'", "'ÿ'", "'Ý'", "'ø'", "'Ø'", "'œ'", "'Œ'", "'Æ'", "'ç'", "'Ç'");
      $replace = array('e', 'e', 'e', 'e', 'E', 'E', 'E', 'E', 'a', 'a', 'a', 'a', 'a', 'A', 'A', 'A', 'A', 'A', 'o', 'o', 'o', 'o', 'O', 'O', 'O', 'O', 'i', 'i', 'i', 'I', 'I', 'I', 'I', 'I', 'u', 'u', 'u', 'u', 'U', 'U', 'U', 'U', 'y', 'y', 'Y', 'o', 'O', 'a', 'A', 'A', 'c', 'C');        

      $name = preg_replace($pattern, $replace, $name);      
      return $name;
  }

So maybe you can read all files, clean the names using this function, and save the files with new name.

In the end, I gave up accents and I now convert all accents to HTML equvalant.So Abaeté; is stored as Abaeté in my DB.

share|improve this answer
    
that would be similar to A, but converting to regular characters, plus an extra step: updating the DB. how would I go about doing that? –  Gaia Jun 13 '11 at 13:36
    
@Gaia - see my updated answer. –  Steven Jun 13 '11 at 15:31
add comment

There are a number of plug-ins for WordPress that will automatically go through your database and correct problems with encoding for UTF-8 and Unicode. I believe one of these would fix your problems.

share|improve this answer
    
Thanks. Out of the ones that are currrently updating and supposed to work with 3.x, the only one that scans archives to supposedly fix the problem did not work. –  Gaia Aug 11 '11 at 15:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.