How to pass JSON UTF-8 from Smarty template to Open Flash Chart 2

Jan 27th, 2010

Recently I ran into the problem with passing UTF-8 JSON from Smarty to Open Flash Chart 2. By default Smarty is striping slashes from all variables that it passes to the template, and JSON is converting every UTF-8 Character with ‘\u’ in the beginning. Of cause Smarty was returning only ‘u’.

To force Smarty to pass variables with slashes you can do next:

1
$this->smarty->assign("chart", addslashes($chart->toString()) );

After that $chart will have correct JSON with correct UTF-8 Characters

Tags: ,
  1. naufal
    Mar 19th, 2010 at 08:31
    Reply | Quote | #1

    please send exemple to me

  2. tyomomy
    Mar 25th, 2010 at 02:00
    Reply | Quote | #2

    Hi.
    this is nice information for me! Thanks :)

    So, will you show me more codes?
    I tried but did’t to make any chart from smarty.
    I want to know how to code php5 and smarty-template.

    My sourse have a problem about never stopping “Loading data” :<

  3. admin
    Apr 1st, 2010 at 10:39
    Reply | Quote | #3

    Guys sorry for long time no response :)

    I will post brief example with Smarty+OFC2 as soon as possible!