I'm writing an own module for my site. Unfortunately I'm Swedish and need to use some weird ("foreign") letters called Å, Ä and Ö in some places. For example in hook_menu (outputting the menu name).

My problem is that these letters doesn't display properly at all. Instead they are substituted with a square or a Chinese character (depending on browser).

I know Drupal can handle these characters. It does so in all types of content, and so on. But apparently not in my own modules...

What am I doing wrong?

Here's a code example from hook_menu:


function sdtabla_menu() {

  $items = array();

  $items[] = array(
    'path' => 'tabla',
    'title' => t('Tablå'),
    'callback' => 'sdtabla_visa',
    'access' => user_access('Visa tablå'),
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

Grateful for any help!

Comments

Standard’s picture

I'm still trying to find a solution to this, but I'm getting kind of desperate.

I've searched around a lot, and found some threads about the database collation. But could this really be a database issue? I mean, are the strings really stored in the database at all?

If the DB matters. What should I change the collation to, and where/how?

Please help!

davedelong’s picture

I would change your database to use the utf8_general_ci encoding. We needed to that on our site (example why) and everything works great now. Before we would get wonky characters. I don't know if this will fix your menu problem, but I don't think it would hurt.

HTH,

Dave

Standard’s picture

Is that only the database, or do I need to do this on individual tables/fields as well?

I've just changed the collation of the database to utf8_general_ci, but unfortunately that didn't have any effect.

davedelong’s picture

If I understand how MySQL works, you'd need to change it for all the tables as well.

Standard’s picture

Just tried that as well...but no success there either :(

I'm thinking the problem must be somewhere else (i.e. not in the database). Drupal's own menu items and titles work. But the ones I create in my own modules does not.

Is there any way to configure the module itself, for using a specific character set?

I don't know if it matters, but I run Drupal 5.3 in English. I have not yet installed any translation files. Could that be the problem?

Standard’s picture

The solution was almost too simple. I use Dreamweaver for writing modules, and for some reason it doesn't save the file as UTF-8...

Anyway. Problem solved. Thanks for all the help!