Hi All,

I am developing a multilingual site in english and french but am having problems with some of the french characters. (The fact that it is multi-lingual doesnt really have much to do with it I think.)

if you goto http://cust-art.com/fr/node/371 you can see the problem. If you scroll down to the bottom of the page you will see a table with text: Qualité la photo. Except instead of é it is a wierd character (that is different in IE and firefox!). The wierd thing in the same table you can see the word Sépia which is displayed correctly.

The text on the right of the table (e.g. Sépia) comes from custom fields of a flexinode.
The text on the left of the table (e.g. Qualité la photo) comes from the code. I have a function to print text :

function msaText($s) {
   static $msaStrings = array(
	'QualityPhoto' => array("Quality of the Photo", "Qualité de la photo"),
	'Background' => array("Background", "Fond"),
	'Character' => array("Character", "Personnage"),
	'Options' => array("Options", "Options")
   );
   $lang = (i18n_get_lang() == 'fr') ? 1 : 0;
   if (isset($msaStrings[$s][$lang]))
      return $msaStrings[$s][$lang];
}

and then i usually do $content.= msaText('blah'); and eventually print $content;

So the special characters that I print through the print command dont work, the ones from node fields do. Do i need to call a special function before printing?

P.S. if I change the character encoding of my browser from unicode UTF8 to Western ISO then all of the printed chars work but then none of the chars in field nodes work!

any ideas?

cheers,

Comments

syllance’s picture

Drupal outputs UTF8 (that's why node fields are displayed incorrectly when you switch to iso8859-1), so I think you should use drupal_convert_to_utf8() function to encode the strings.

the text with accents in your function have no encoding, and that's why they're displayed strangely. node fields text is correctly encoded by drupal before being displayed.

not tested, but may help.

good luck

high1memo’s picture

Thanks for that, but i just found out I was totally wasting time!! thats what the t() function does!!! So I didnt need to create my own function and a massive array in code, or go through all of my modules adding the msaText() function etc. etc. I could have just used the t() function and then add the strings with translations through the localization section!!! So much easier!!! AND no problem with encoding!!!! DOHH!!!