views:

100

answers:

1

Hi,

I'm using JSON to integrate open flash chart to my web page.

When I have a Right to Left language string which contains more the one word the JSON encodes it backwards (For example: "Hello world" is encoded as "world hello").

The string is extracted from a database, there for can be of any language.

How do I force the correct encoding of Right to Left language without ruining other languages?

Thanks

+1  A: 

Hi,

After a lot of digging it seems to be known issue with the open flash chart package. The only way to deal with this issue is to identify the language, reorder the words and only then send it to eh JSON.

To identify Hebrew I used this:

function getOrderedString($string)
{
    $letters = utf8_encode("[א-ת]"); //Hebrew charecters
    if (preg_match("/".$letters."/", $string)) 
    {
        //If the string contains any hebrew charecters reorder it
        $split = explode(" ", $string);
        if (count($split) == 1)
            return $string;
        $orderedString = "";
        foreach($split as $word)
        {
            $orderedString = $word." ".$orderedString;
        }
        return $orderedString;
    }
    return $string;
}
bizz