Finally out of MySQL encoding hell [en]

[fr] Description de comment je me suis sortie des problèmes d'encodage qui résultaient en l'affichage de hiéroglyphes sur tous les sites hébergés sur mon serveur.

It took weeks, mainly because I was busy with a car accident and the end of school, but it also took about two real whole days of head-banging on the desk to get it fixed.

Here’s what happened: remember, a long time ago, I had trouble with stuff in my database which was supposed to be UTF-8 but seemed to be ISO-8859-1? And then, sometime later, I had a weird mixture of UTF-8 and ISO-8859-1 in the same database?

Well, somewhere along the line this is what I guess happened: my database installation must have been serving UTF-8 content as ISO-8859-1, leading me to believe it was ISO-8859-1 when it was in fact UTF-8. That led me to try to convert it to UTF-8 — meaning I took UTF-8 strings and ran them through a converter supposed to turn ISO-8859-1 into UTF-8. The result? Let’s call it “double-UTF-8” (doubly encoded UTF-8), for want of a better name.

Anyway, that’s what I had in my database. When we upgraded MySQL and PHP on the server, I suddenly started seeing a load of junk instead of my accented characters:

encoding-problem-2

What I was seeing looked furiously like UTF-8 looks when your server setup is messed up and serves it as ISO-8859-1 instead. But, as you can see on the picture above, this page was being served as UTF-8 by the server. How did I know it wasn’t ISO-8859-1 in my database instead of this hypothetical “double-UTF-8”? Well, for one, I knew the page was served as UTF-8, and I also know that ISO-8859-1 (latin-1) served as UTF-8 makes accented characters look like question marks. Then, if I wanted to be sure, I could just change the page encoding in Firefox to ISO-8859-1 (that should make it look right if it was ISO-8859-1, shouldn’t it?) Well, it made it look worse.

Another indication was that when the MySQL connection encoding (in my.cnf) was set back to latin-1 (ISO-8859-1), the pages seemed to display correctly, but WordPress broke.

The first post on the picture I’m showing here looks “OK”, because it was posted after the setup was changed. It really is UTF-8.

Now how did we solve this? My initial idea was to take the “double-UTF-8” content of the database (and don’t forget it was mixed with the more recent UTF-8 content) and convert it “from UTF-8 to ISO-8859-1”. I had a python script we had used to fix the last MySQL disaster which converted everything to UTF-8 — I figured I could reverse it. So I rounded up a bunch of smart people (dda_, sbp, bonsaikitten and Blackb|rd — and countless others, sorry if I forgot you!) and got to work.

It proved a hairier problem than expected. What also proved hairy was explaining the problem to people who wanted to help and insisted in misunderstanding the situation. In the end, we produced a script (well, “they” rather than “we”) which looked like it should work, only… it did nothing. If you’re really interested in looking at it, here it is — but be warned, don’t try it.

We tried recode. We tried iconv. We tried changing my.cnf settings, dumping the databases, changing them back, and importing the dumps. Finally, the problem was solved manually.

  1. Made a text file listing the databases which needed to be cured (dblist.txt).
  2. Dumped them all: for db in $(cat dblist.txt); do mysqldump --opt -u user -ppassword ${db} > ${db}-20060712.sql; done
  3. Sent them over to Blackb|rd who did some search and replace magic in vim, starting with this list of characters (just change the browser encoding to latin-1 to see what they look like when mangled)
  4. Imported the corrected dumps back in: for db in $(cat dblist.txt); do mysql -u user -ppassword ${db} < ${db}-20060712.sql; done

Blackb|rd produced a shell script for vim (?) which I’ll link to as soon as I lay my hands on the URL again. The list of characters to convert was produced by trial and error, knowing that corrupted characters appeared in the text file as A tilde or A circonflexe followed by something else. I’d then change the my.cnf setting back to latin-1 to view the character strings in context and allow Blackbr|d to see what they needed to be replaced with.

Thanks. Not looking forward to the next MySQL encoding problem. They just seem to get worse and worse. (And yes, I do use UTF-8 all over the place.)

Dell s'y met aussi! [fr]

[en] Announcing Dell's blog.

A surveiller: le blog de Dell. Jetez un oeil, du coup, à ce qu’en disent les blogueurs. Vous pouvez aussi voir ce que raconte la blogosphère au sujet de Dell. Comme quoi, les blogs ce n’est pas que pour les PME, ça marche aussi dans les grandes boîtes!

Technorati est un service vraiment utile, dommage que tout le monde ne le connaisse pas encore! Robert Scoble nous rapportait il y a quelques jours comment il a montré Technorati à une équipe de dirigeants Nestlé: ils ignoraient totalement qu’ils pouvaient suivre en temps quasi-réel ce qui se dit au sujet de leur marque! (Il y a un peu de bruit, c’est sûr, mais garder un oeil là-dessus peut s’avérer loin d’être inutile.)

Bloggy Friday de juillet un peu spécial [fr]

[en] Bloggy Friday and birthday party all-in-one: this Friday in Lausanne.

Mise à jour 06.06: vu le (grand) risque d’orange, la fête aura lieu au Reighikan Dojo. C’est en ville de Lausanne près de l’Hôtel de Police (derrière le Tunnel), à la rue de l’Industrie 10 (dans la cour intérieure, en face de Textura, Théâtre Pull-Off, etc). Grillades toujours possibles 😉

Comme annoncé il y a quelque temps le Bloggy Friday de juillet est un peu spécial: primo, il se passe au bord du lac, et deuxio, il s’intègre à mon traditionnel barbecue d’anniversaire — ce qui a pour conséquence qu’il y aura des non-blogueurs présents.

Que ceci ne vous arrête pas! Je vous attends dès 19h00 au bord du lac à Vidy. J’ai tenté de faire un vague plan: http://flickr.com/photos/bunny/179905099/

Via les transports publics, prenez le bus numéro 2, sortez à euh… Bois-de-Vaux (si je ne me trompe pas), descendez direction lac et marchez ensuite direction Genève. Si ça pue, c’est la STEP, et c’est un peu trop loin. Le mieux, appeler le 078 625 44 74 et la standardiste vous aidera.

Amenez un quelque chose à griller et un quelque chose à partager, plus de quoi vous amuser si vous êtes du genre frisbee/foot/échecs.

Laissez un petit mot si vous pensez être de la partie, et on vous garde un petit coin de grill!

Théâtre au CPO [fr]

[en] If you're in Lausanne, go and see "Deus ex machina" at the CPO tonight.

Deus ex machina -- autosatisfaction

Si vous n’avez rien de prévu ce soir, allez voir “Deus ex machina”, une pièce écrite et jouée par la compagnie des cerceaux, sous la direction de Sonia Piscitelli.

Mon frère y joue, je suis allée la voir hier soir, et j’ai beaucoup ri! Déçue en bien, comme on dit dans notre pays. En quelques mots: Zeus s’ennuye ferme, regrette son pouvoir du temps de l’Antiquité, et met en place un plan machiavélique pour que les humains croient à nouveau en lui.

Deus ex machina -- paperasse

Représentations à 18h30 ce soir, et 20h00 vendredi (il y a en a d’autres, le rôle de mon frère étant dédoublé, mais je ne sais pas quand). Le spectacle a lieu au CPO (Centre Paroissial d’Ouchy) à Lausanne. Entrée gratuite, sortie donnante (tirelire).

Suggestion: sortez votre mythologie grecque du placard, vous rirez d’autant plus.

Gandi fait peau neuve [fr]

[en] If you haven't yet checked it out, go and see Gandi.net's new design.

Je ne le vois que maintenant, mais au cas où vous seriez encore plus à  la traîne que moi, allez regarder la nouvelle interface de Gandi.net. Gandi (sans h!), c’est l’endroit où aller pour enregistrer vos noms de domaines. Souvent, votre hébergeur vous proposera des formules hébergement+nom de domaine: très joli, jusqu’au jour où vous voulez changer d’hébergeur et où ça devient compliqué.

Tous chez Gandi!

Inspiration culinaire de ce soir [fr]

[en] I threw a few things together in the pan tonight and it ended up being a very nice tomato-cream sauce. Here's the recipe.

Celui-ci, je le fais surtout pour moi, mais aussi pour vous, parce que franchement, mon improvisation culinaire tardive de ce soir est fort bonne.

J’ai fait des pâtes à  l’ail d’ours (Migros, elles sont délicieuses) avec la sauce suivante:

– une demi-boîte de tomates concassées
– un mini-berlingot de crème entière (125ml)
– un petit sachet de parmesan (50g)
– quelques giclées de jus de citron
– généreusement ajouter du poivre au citron
– un peu de bouillon de poule en poudre pour saler
– quelques fourchetées de câpres (miam!)
– un petit peu de sel d’ail et de mélange de condiments à  l’italienne

Faire chauffer la sauce après avoir tout mélangé, puis rajouter aux pâtes. Un peu trop de sauce pour une personne, mais c’est pas grave!

Google Calendar pour blogueurs de la région [fr]

[en] I set up a Google calendar for local bloggers.

Je découvre Google Calendar et j’aime bien. Ce qui est sympa, c’est qu’on peut importer/exporter en format XML ou iCal.

Du coup, je tente une expérience: j’ai créé un calendrier blogosphérique suisse romand (il s’appelle ‘Blogueurs Suisse Romande’ si vous voulez le trouver depuis gCal). En principe, vous devriez pouvoir ouvrir cette adresse (je ne suis pas trop sûre comment) et vous inscrire au prochain Bloggy Friday. Essayez, et on en parle ce soir!

Ah oui: format XML pour ceux qui veulent.

En principe, le bouton ci-dessous devrait vous ouvrir le calendrier dans Google:

Should I sell it? [en]

[fr] Est-ce que je devrais vendre mon blog?


My blog is worth $93,149.10.
How much is your blog worth?

Inscriptions Bloggy Friday de ce vendredi [fr]

[en] Bloggy Friday this Friday in Lausanne. Please sign up in the comments of this post if you think you'll come!

Comme annoncé, le Bloggy Friday de juin a lieu ce vendredi à  l’Evêché (au bout du Pont Bessières, près de la Cathédrale) dès 19h30.

Merci de vous inscrire ici si vous pensez venir, histoire que je réserve une table de la bonne taille.

Nous avons déjà :

Excusée:

Merci, et à  demain (!) nombreux j’espère!