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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pablobm’s picture

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):

    function process($in_string) {
    return preg_replace('{(<a href=")(#[^"]*")}', '$1' . request_uri() . '$2', parent::process($in_string));
  } // function process

Should be changed to this:

    function 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.php as well. The author forgets that in PHP, 0 !== NULL but 0 == NULL. This happens in the next piece of code (from line 4080):

  function 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:

  function 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.

Tommy Sundstrom’s picture

FileSize
14.96 KB

Here's a patch of textile.module to fix the problem with accented characters.

Use together with the patch of Textile.php

Tommy Sundstrom’s picture

FileSize
145.21 KB

Here is a patch of Textile.php to fix accented chars

Use together with the patch of textile.module

Tommy Sundstrom’s picture

FileSize
1.21 KB

SORRY included the full files not the patches.

Here we go again.

Tommy Sundstrom’s picture

FileSize
2.87 KB

and the other patch

jhriggs’s picture

Assigned: Unassigned » jhriggs

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.

Anonymous’s picture