Problems with accented characters
Tommy Sundstrom - October 7, 2004 - 08:51
| Project: | Textile |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | jhriggs |
| Status: | closed |
Description
There is a problem with accented characters when using the textile module, see http://drupal.org/node/10268 and http://drupal.org/node/6881
I belive the options['char_encoding'] should be set to 0 as default OR that a trouble shooting section should be added to the installation instructions telling about this solution.
Possibly related: option charset is set to iso-8859-1. I thougt Drupal was strictly utf-8.

#1
Yesterday I had a hard fight against this module due to this problem. Finally, I think I came up with the error.
Initially, it may seem the problem is the module doesn't tell to Textile to work with UTF-8 encoding, which is the one used by Drupal.
It should be fixed in the code at the end of the module, inside the DrupalTextile class. (This is because all Drupal processing is supposed to deal with UTF-8).
One way to do so would be changing the next code (from line 516):
<?phpfunction process($in_string) {
return preg_replace('{(<a href=")(#[^"]*")}', '$1' . request_uri() . '$2', parent::process($in_string));
} // function process
?>
Should be changed to this:
<?phpfunction process($in_string) {
$this->charset('utf8'); // This is the important change
return preg_replace('{(<a href=")(#[^"]*")}', '$1' . request_uri() . '$2', parent::process($in_string));
} // function process
?>
However, this is not enough. There is an error in the
textilephp/Textile.phpas well. The author forgets that in PHP,0 !== NULLbut0 == NULL. This happens in the next piece of code (from line 4080):<?phpfunction char_encoding($char_encoding = NULL) {
if ($char_encoding != NULL) {
$this->options['char_encoding'] = $char_encoding;
}
return $this->options['char_encoding'];
} // function char_encoding
?>
That should be:
<?phpfunction char_encoding($char_encoding = NULL) {
if ($char_encoding !== NULL) { // Error corrected
$this->options['char_encoding'] = $char_encoding;
}
return $this->options['char_encoding'];
} // function char_encoding
?>
With both changes, accents should be not a problem for textile.module anymore.
#2
Here's a patch of textile.module to fix the problem with accented characters.
Use together with the patch of Textile.php
#3
Here is a patch of Textile.php to fix accented chars
Use together with the patch of textile.module
#4
SORRY included the full files not the patches.
Here we go again.
#5
and the other patch
#6
There were two things going on here. First, the module did not specify utf-8 as the charset for the Textile class. Second, there was a bug in TextilePHP that caused it to ignore false values for char_encoding. This is all addressed in the latest files in CVS. The lastest version for both 4.5 and 4.6 should work properly.
#7