Erik Dahlstrand dijo [Tue, Mar 24, 2009 at 11:24:12AM -0700]:
> 
> I'm no longer sure it is a HAML problem...
> 
> A simple template
> 
> %h1
>   = h @news_item.title
> 
> 
> As long as title contains only ASCII characters there is no problem.
> When title equals e.g. "this is a string containing å ä ö" it fails.
> 
> incompatible character encodings: ASCII-8BIT and UTF-8
> 
> Maybe it is the sqlite3-ruby driver?

This is not related to Haml, and not even to Rails, but to the way
your data is stored in the database. You can mitigate the problem by
specifying the right encoding in your database.yml - i.e. 

development:
  adapter: sqlite3
  encoding: latin1
  database: mydb.sqlite

The default (and preferred) encoding is 'unicode' - I am not sure if
latin1 is the correct identifier (even more, if it is right in your
locale).

What is the problem behind this? For many many years (while we used
the 8-bit ASCII set), any byte sequence was representable as a
character string. However, 8 bits are not enough for anybody(tm). As
many different alphabets (as well as many different modifications to
existing alphabets) require being representable, several "codepages"
were created - i.e. latin1 through latin15, each of them good for a
subset of countries. 

I gather from your name that you are German - So latin1 might solve
most of your needs. It solves mine (against what you'd guess from my
name, I am Mexican). Latin1 (and Latin15, which basically trades a
very seldom used sign, ¤, for the Euro symbol, €) is meant for Western
European languages.

However, a user in your site might be (or a news item title might talk
about) of Slavish ascent, having ĺ, č, ž, ŕ or other such fun
characters. If you go for this workaround, those characters (belonging
to Latin2) will be respectively represented as å, è, ¾, à (if I am not
mistaken). 

So, what is the preferred way out? To migrate your database to a full
UTF8 (Unicode) character set.

Greetings,

-- 
Gunnar Wolf - [email protected] - (+52-55)5623-0154 / 1451-2244
PGP key 1024D/8BB527AF 2001-10-23
Fingerprint: 0C79 D2D1 2C4E 9CE4 5973  F800 D80E F35A 8BB5 27AF

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to