(You can choose or or both)

Wednesday, January 31, 2007

Detect bad encoding javascript html utf-8t

(Encore du technique, merci pour votre patience).

(More technical stuff, thanks for your understanding).

Problem: you have a page that has accented characters, that is supposed to be opening in utf-8 charset encoding, but sometimes doesn't (maybe I'm the only person that ever had this problem..., in my case it was the HTML editor Xinha, opened in a popup).

How to at least warn your users that there is a problem? Can javascript detect the encoding of the page in which it is placed?

Well, no, and yes.

This is the solution I found, which is rather elegant (I feel):
if ('é'.length==2) alert('Houston, we have a problem');

How does it work?

I may be wrong, but as I understand it, 'normal' text takes up one byte per character. Unicode takes up two bytes per character. UTF-8 takes up one byte, except for 'problem' characters, for which it users two bytes.

So if a utf-8 encoded page is badly intepreted as being 'normal', an 'é' character (which takes up two bytes), will be interpreted as two one-byte characters.

Conversely, if the browser thinks the page is utf-8, it will interpret the 'é' combination as one character.

So if javascript tells you the length is two, you know that you're not in UTF-8.

(Last detail, and here I'm in unknown territory - contrary to the postscript in my previous post about utf-8, you shouldn't save web pages as UTF-8, but normal files, but with the charset meta tag set tu utf-8. I think I'm right about that, but no idea why...)

Tuesday, January 30, 2007

Dire rear ... Vidange


C'est pas la top forme chez nous ces jours - Kalia est malade depuis la fin de la semaine passée, et j'étais à la maison aujourd'hui complètement KO et en train de faire un purge involontaire.

Pour l'instant, Mamma n'a pas succombé, et tant mieux, deux malades à la fois c'est déjà assez !


Not on the top of our form here right now. Kalia's beek 'ick since last week, and I was off work today with fever, dia...wotsit etc..

Fortunately, Mamma isn't ill yet - hope it stays that way - two at a time is already plenty!

Friday, January 26, 2007

Before & after ... Avant & Après


Ils sont venus enlever la vieille moquette et remettre en état le parquet qui était en dessous. Seulement que lorsqu'ils ont enlevé la moquette, ils ont découvert pourquoi elle avait été mise - un gros bout de parquet manquant était remplacé par une planche de contre-plaqué.

Du coup ils ont du poser du laminé par dessus.

Mais ce n'est pas plus mal, c'est plus clair.

Last week the chappy came to rip up the old carpet in the hall and do up the parquet whic was underneath. But when he took the carpet up, he discovered the reason why they put it there - there was a large chunk of parquet missing - replaced with some plywood.

So in the end they covered it over with another layer of pre-fabricated parquet.

It's lighter than the other parquet would have been, so we're quite pleased - now just got to do up all the paintwork and put the furniture back!

Sunday, January 21, 2007

Kid's games ... jeux pour tout-petits


Voilà un site avec tout plein de liens sympas sur des jeux internet pour des petits, ces temps-ci avec Kalia on est en train d'apprendre l'alphabet - avec un accent américain...

Here's a site with tons of links to baby- and toddler-level internet computer games. At the moment we're working our way through the alphabet with Kalia - albeit with an american accent.

Thursday, January 18, 2007

Exile


(Photo prise par une amie qui était ici quelques jours en vacances)

Nous serons exilés jusqu'à samedi matin.

Demain matin il y a des ouvriers qui viendront pour enlever la moquette dans le hall, et remettre en état le parquet qui est dessous. A cause des produits chimiques c'est conseillé de rester loin pendant quelques temps.

Heureusement qu'on a des amis sympas qui acceptent des squatters !

(Photo taken by a friend who was here a few days on holiday)

We're being exiled from tomorrow morning till Saturday. Workmen are coming to rip up the carpet in the hall and do up the parquet which is underneath. Because of the fumes given off by the varnish we've been advised to keep clear for a night at least.

Fortunately we have friends who are prepared to put up with us squatting at their place.

Monday, January 15, 2007

DOM Inspector CSS Style Rules broken (bug/problem/empty)

(Le service normal reprendra bientôt).

Cet article est le plus visité de tout mon blog, je ne sais pas s'il faut en être fier ou non ! Pour info, d'après ce que je constate, vous devrez refaire cette manip à chaque mise à jour de Firefox.

Bonjour, si vous êtes arrivés ici pour des problèmes de DOMInspector qui n'affiche plus rien dans la partie CSS Style Rules, voilà la solution:

1. Fermer Firefox
2. Trouver le fichier xpti.dat (pour Windows en anglais, c'est c:\Documents and
Settings\username\Application
Data\Mozilla\Firefox\Profiles\xxxxxxxx.default\xpti.dat)
3. Ouvrir avec un éditeur texte comme Notepad, Notepad2, UltraEdit ou CrimsonEdit
4. Trouver la ligne qui contient le texte : inIDOMUtils
5. Remplacer la partie suivant cette texte avec : {78fd16c2-bdfb-4b1d-8738-d536d0a8f430},0,-1,1
6. Sauvegarder le fichier, fermer, et ouvrir Firefox

(La page où j'ai trouvé cette information est ici)

(Normal service will resume shortly)

This is the most visited page on my blog, not sure whether that is a compliment or not! Further info based on my experience is that you wil have to repeat this procedure after every update/upgrade.

If you've come here from Google looking for a solution to your empty CSS Style Rules in the Dom Inspector, here is the solution:

1. Close Firefox
2. Locate this file: xpti.dat (in Windows, it's something like c:\Documents and
Settings\username\Application
Data\Mozilla\Firefox\Profiles\xxxxxxxx.default\xpti.dat)
3. Open with a text editor such as Notepad, Notepad2, UltraEdit ou CrimsonEdit
4. Fine the line with the following text: inIDOMUtils
5. Replace the part after inIDOMUtils with: {78fd16c2-bdfb-4b1d-8738-d536d0a8f430},0,-1,1
6. Save the file, close it, and open Firefox

(The page where I found this info is here)

Saturday, January 13, 2007

Bending the chain ... Plier la chaîne

Peine à télécharger les photos ce soir, je commence déjà à écrire et on verra bien si à la fin la photo arrivera !

Ce soir, une révélation scientifique inouïe - une première mondiale (non, je n'ai pas vérifié)

Est-ce que vous vous rappelez quand on vous a appris à aller sur une balançoire ? Il faut plier les jambes dans un sens, puis les étendre dans l'autre. Puis vous avez essayer et rien ne se passait, jusqu'à ce qu'au moment donné, quelque chose s'est passé et vous avez pigé le truc - ou plutôt c'est votre corps qui a compris.

Et maintenant si vous devez apprendre à quelqu'un d'autre, vous leur diriez aussi qu'il faut commencer par plier les jambes.

Après une longue analyse de cette question (j'ai largement le temps, une fois que Kalia est installée sur sa balançoire, elle ne décolle plus - et non, elle n'a pas encore appris, d'où ma réflexion), je suis arrivé à la conclusion que les jambes et les genoux n'ont rien à voir, ce qui importe c'est de plier la chaîne (ou la corde). C'est ça qui fait bouger la balançoire.

Dire qu'il y a des universitaires qui font des thèses pour prouver des choses d'une pareille importance, et je vous le livre ici, gratuitement...

There seem to be problems with uploading photos this evening...

Do you remember learning how to swing on a swing? Someone told you to stretch your legs to go forward, and bend them to go back. And you tried. And nothing happened. Then eventually your 'got it' (or your body did), and it worked.

And now, if you were to teach someone else, you'd tell them to start by bending their legs.

Having analysed this question for a long time (I have plenty of time to do this when Kalia is on the swings - once she's on she doesn't budge! And in case you wondered, no she hasn't learnt yet, which is why I think about it), I have come to the conclusion that legs and knees don't have anything to do with it. What counts is bending the chain (or the rope). That's what makes the swing move.

Given that people do doctorates to prove this kind of thing, I think you should be greatful that I choose to reveal the results of my research with you for free, here on my blog...

Wednesday, January 10, 2007

Sleeping rough ... SDF ?


Je vous promets qu'elle a commencé sur le matelas !

Si notre fille n'est pas somnambule, elle est au moins une dormeuse gymnaste, et on peut souvent la retrouver la tête en bas du lit, ou vers la Mecque (sur les genoux avec les fesses en l'air !)

Je regrette de vous avoir délaissé ces temps. Ce n'est pas que je n'ai pas d'idées, mais comme j'ai dit la dernière fois, je me pose la question d'un deuxième blog. S'il y a en a parmi vous qui aurait une bonne idée pour un 'url' de deuxième blog (de la forme quelquechose.blogspot.com) qui n'est pas déjà pris, je suis preneur.

Pour ceux qui savent l'anglais, et qui ne sont pas trop sensible aux gros mots, il y a ici un article à la fois drôle est sérieux (satirique?) intitulé "7 raisons que le 21ème siècle vous rend déprimé"

She did start out on the mattress, I promise!

Our daughter may not be a sleep walker, but she is definitely a gymnastic sleeper. It's not unusual to find her in all sorts of funny places or positions - with the head at the bottom of the bed, or pointing towards Mecca (on her knees with her bum in the air!).

I'm sorry that I've not been very prolific of late. As I said in my previous posts, it's not for lack of ideas, just not knowing where to put them. If you can think of a decent url (in the form something.blogspot.com) which isn't already taken, let me know. Or maybe I should bite the bullet and buy my own domain?

If you are not too sensitive to strong language, here is an excellently-written article titled "7 reason the 21st century is making your miserable". It's both funny and serious - I think they call it satire...

Thursday, January 04, 2007

Money laundering ... argent propre


(Photo de Kalia qui essaie les lunettes de sa mère).

La Suisse a une petite réputation pour le blanchiment d'argent. Je peux dorénavant confirmer que l'argent suisse peut effectivement être lavé sans le moindre problème.

Il se trouve que j'avais laissé mon cadeau de Noël (des sous) dans la poche de mon pantalon, qui est passé aujourd'hui à la machine à laver - et aussi au séchoir il me semble.

Malgré une petite frayeur (tempérée par des "ce n'est que de l'argent après tout" à moitié convaincus), les billets en sont sortis indemnes, même si un peu humides.

(Ah oui, j'allais oublier - bonne année !)

(Kalia trying on Mama's glasses)

Switzerland has a not-entirely-unjustified reputation for cleaning up dirty money. I can now confirm that swiss money can effectively be laundered with no undesirable side-effects.

It so happens that I left my Christmas money in the back pocket of my trousers - said trousers were washed and tumble-dried today.

Despite a moment of mild panic (accompanied by a half-convinced "after all, it's only money"), the notes came out fine, if a trifle damp.

(Happy New Year, by the way)

Friday, December 22, 2006

Sleeping beauty ... belle dormante


J'ai une difficulté avec ce blog. J'ai pas mal de trucs 'techniques' que j'aimerais bien mettre sur internet quelque part (même si ce n'est que pour pouvoir m'y reférer en cas de besoin). Idéalement, pour garder ce blog 'pur', je devrais en démarrer un autre. Mais étant donné que j'ai déjà de la peine à nourir celui-ci, ce n'est pas sûr que j'y arrive.

Enfin, on verra bien - il y a encore toutes les question géo-politiques qui m'intéressent.

Puis des questions de foi, de théologie aussi.

Et ma fille est belle.

Et joyeux Noël...

I'im in a bit of a quandry about this blog. The problem is, I've got quite a few technical bits I'd quite like to post somewhere - even if its for my own reference. Ideally, to keep this blog 'pure', I ought to start another one. But given the difficulty I have keeping this one going, I don't know if I'd manage.

And then there's my occasional geo-political musings.

And the theological ones to.

And isn't she cute?

And Happy Christmas!

(This guy did this to keep his first blog on the straight and narrow.)

Monday, December 18, 2006

Disconcerting information ... Une information déroutante


Un collègue m'a parlé d'une nouvelle langue de programmation - enfin, nouvelle pour moi. Ca s'appelle Rebol, mais là n'est pas mon propos.

Un des premiers exemples des 'tutorials' était le program pour calculer combien de jours on a. C'est une exercise que je m'amusais à faire dans des cours (ou réunions d'église), trop longs ou ennuyeux. A l'époque où il ne fallait pas trop long pour calculer... en tout cas j'étais en dessous des 10 mille !

C'est quand on voit son existence réduit à un seul chiffre que la phrase 'ses jours sont comptés' prend tout son sens.

Tous nos jours sont comptés, et chaque jour compte.

(J'ai écrit ceci le 18, mais j'ai oublié de le mettre en ligne)

A colleague told me about an new programming language - new to me, in any case. It's called Rebol.

One of the first scripts in the tutorial was a program to calculate how many days old you are. It's something I used to try and work out in my head, during long and boring lessons (or church services). At the time, it didn't take too long to work out - and in any case it wasn't more than 10 thousand!

Seeing your life reduced to just one number reminds one of the expression "his days are numbered".

I guess all of our days are numbered, and every one counts.


(I wrote this on the 18th, but I forgot to put it online.)

Saturday, December 16, 2006

Mince pies


J'ai trouvé du 'mincemeat' (garniture composée de fruits secs et d'épices) dans un magasin en ville.

Du coup j'ai pu faire des mince pies, et Kalia les aime !

Donc elle a quand même quelques gènes English.

A friend told me there was a shop in town which sold mincemeat. Couldn't believe it but it turned out to be true!

So I bought some today and made mince pies this evening - and Kalia likes them!

So she is a tiny bit English (what with that and liking Marmite too).

Saturday, December 09, 2006

Moving ... déménagement


Non, non, on ne change pas d'appartement, mais on déménage quand-même ! Les bibliothèques s'en vont du salon dans le bureau, où je m'arrache les cheveux pour savoir comment les aligner avec passé 2cm de dénivelé. On a des nouvelles chaises pour la salle à manger - jusqu'à maintenant on a fait avec des chaises récupérées, dont certaines ont cédé au fil des ans à l'embonpoint de nos invités. (On attend encore pour acheter la table).

Et puis on a acheté des meubles pour la chambre à coucher, dont voici les tiroirs, à moitié montés. Kalia s'est fait un plaisir fou à "m'aider" à les monter, et puis elle rentre dedans pile-poil.

Not moving house, but moving pretty much everything else! The bookcases have moved into the 'office' - where I'm still wondering how to line them up with a floor that is not level at all. We've finally bought some chairs for the dining room, after making do for years with an assortiment of different shapes and sizes recovered from various places. (We're waiting to buy the table now).

And we bought some bed-side tables and this chest of drawers, which Kalia had great fun "helping" me to put together. And she was very pleased to find that it was just her size!

Tuesday, December 05, 2006

Another photo ... Une autre photo


N'ayant pas beaucoup de temps pour en faire plus, je vous laisse quand même une photo de la miss. Elle est chou, vraiment. Très sociable, souriante et joyeuse. On est reconnaissant et content. Elle découvre tout le temps des nouveautés. Aujourd'hui elle s'est amusé un bon moment à mettre des choses dans une boîte, puis le vider, puis les remettre, puis revider.

Elle s'intéresse aussi aux limites de son corps. Elle grimpe, et roule, et teste son équilibre, et parfois les réactions rapides de ses parents !

Not much time to say more, so here is a photo of little My. She really is that sweet, honest! Very sociable, friendly, happy-natured. We're very greatful and pleased. She keeps discovering new and interesting things. This evening she spent a good while putting things in a box, emptying it, putting them back etc (like Eeyor).

She's into checking out her physical limits as well. Climbing on furniture, crawling under the bed, testing her balance, and her parents lightning reactions at times!

Saturday, December 02, 2006

Geopolitical indignation ... indignation géopolitique

C'est rassurant de constater que je ne suis pas le seul à être atteint des indignations géopolitiques. Voilà un article écrit (in English) par la mari de ma cousine - ils sont en Inde pour travailler avec les séropositifs...

Reassuring to see that I am not the only person to succumb to geopolitical indigation. Here is a post from my 'cousin-in-law', who arguably puts his indignation to better uses than I do...

Thursday, November 30, 2006

Pretty girl ... elle est pas belle ma fille?


No comment.

A bit busy this evening, sorry. So here's a photo to keep you happy.

Wednesday, November 22, 2006

Excel CSV UTF-8 unicode accents characters


(Désolé, encore un article technique, en compensation - une photo de 'stinguette prise ce matin. J'expérimente aussi avec les 'catégories' dans ce blog - vous verrez que cet article est 'techno'; alors technophobes s'abstenir).

(Sorry, another technical post. But at least this time there's a photo of Little My, taken this morning. I'm also experimeting with 'labels' on this blog - you will notice that this one is 'Techno' - though not of the musical sort).

(UPDATE 2008-09-05: This is by far the most read post on my blog. Leave a little comment for me if you find it useful, I like to hear your stories)
Hello, welcome to my blog if you came here searching in desperation for a solution to a stupid problem.

The problem is that Excel won't correctly interpret accents in a csv file with utf-8 encoding. So the following csv:
id;name
4;Hélène

Looks like this when opened in Excel:
id name
4 Hélène

Do you want to know the solution?
Do you really really want to know?
Are you prepared to abandon all coding niceties and foibles about doing things the right way?

The solution (the only one that I have found/worked after trawling through lots of google) is to save your data as html, but to give the file a .xls extension.

Don't ask me why, but despite being flummoxed by the csv, Excel is smart enough to eat the html, accents and all.

Here is an example of the same data - with the necessary charset declaration.
<html>
<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
<table>
<tr>
<th>id</th>
<th>name</th>
</tr>
<tr>
<td>4</td>
<td>Hélène</td>
</tr>
</table>
</html>

You can even do a bit of styling on the results:
<style>
table, td, th {border:solid black}
table {border-collapse:collapse;border-width:0 0.5pt 0.5pt 0}
td, th {border-width:0.5pt 0 0 0.5pt}
</style>

[Postscript for Anonymous (in comments below) - if using Notepad or equivalent, you have to Save As UTF-8, otherwise it won't work.]