Arabic Charset and RedCloth

October 23rd, 2009

The Berkman Center has friends all over the world and just about every website we have requires language support.

We recently had an issue with RedCloth and the Arabic character set.  When saving content, line breaks disappear when you create a new RedCloth object.  It’s as if the Arabic line break character is ignored.

I cut and paste my Arabic document into the text area box on the front page of the RedCloth site.  And the line breaks show up fine there.  So, the ajaxy bit works fine.  Perhaps the culprit lies in the .to_html method.

This could be an issue with the Windows-1256 charset for Arabic.  I wouldn’t be suprised if the problem doesn’t occur on a Mac which I assume uses ISO 8859-6.

Anyway, the workaround is easy.  Just use html line breaks: <br />

UPDATE: Had friends test this out on the mac using a variety of browsers and still had the same problem.  On either Windows or Mac, typing the enter key using the Arabic charset uses a strange character that RedCloth/Textile doesn’t understand.

Entry Filed under: Professional, Ruby on Rails

4 Comments Add your own

  • 1. Anas Qtiesh  |  October 26th, 2009 at 2:28 pm

    The easy fix to Left to Right languages in HTML is the following:
    arabic text here

  • 2. Anas Qtiesh  |  October 26th, 2009 at 2:30 pm

    Ooops you need to do use the following HTML tag:

    And then put Arabic text, and then close the HTML tag.

  • 3. Anas Qtiesh  |  October 26th, 2009 at 2:31 pm

    div style=”direction:rtl;text-align:right”
    this is the tag, hope it shows this time.

  • 4. lianaleahy  |  October 26th, 2009 at 2:35 pm

    When both English and Arabic are used in a sentence, the formatting breaks. The solution is Anas’ fix above. Just hardcode the html yourself.

    Thanks, Anas!

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


RSS Berkman Gender & Tech

RSS Tweets

Tags

Meta