Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Japanese don't display correctly

edited February 2012 in I18n


I'm Japanese, so put site tile in Japanese, and it didn't display correctly. And I changed block name to Japanese, also incorrectly.

I just check DB, wrongly saved. So I suspect your saving way or input filter wrong. (I didn't check code.)

Maybe you don't intend English only. :D Your top page say 'Elefant apps are automatically i18n aware, with built-in multilingual capabilities and locale awareness.' and set db's table as 'utf8-general-ci'. :D

If you don't know any Japanese, so c&c this '愛と勇気はデバッグに必要' into name area, and check db tables.


  • Just testing this out. Here is what I've found so far:

    • Pasting into the page body works fine
    • Looking at the database, the data seems okay (sqlite, haven't checked mysql yet)
    • In the page title, it gets converted to "愛と勇" etc.
    • If I change {{ title }} to {{ title|none }} to disable filtering, the title shows correctly
    • Blocks seem to save okay too (title and body)
    • Editing a page or block again converts the title to "愛と勇" in the text input field (but not the body)

    So it seems there are a couple issues:

    1. Template::sanitize(), which just calls htmlspecialchars($val, ENT_QUOTES | ENT_IGNORE, 'UTF-8') is breaking the text.
    2. Some or all of the edit text fields currently aren't respecting the special characters.

    The second issue is likely caused by the first. I'll keep at it and see how I can solve that and go from there.

    Thanks for posting this!

  • edited December 2011

    Small correction: The characters are being saved to sqlite as 愛と勇 entities. That's why htmlspecialchars is changing the &'s to &'s.

  • Dumping the $_POST input, it appears PHP is receiving the text encoded as entities already, so that is what is stored. I suppose the workaround then is to not filter values like the title in the layout (changing {{ title }} to {{ title|none }}), so they'll show correctly.

    In the edit forms however, I'll need to change them to filter for quotes, so a value="{{ title }}" won't screw up if the title contains a double-quote. That appears to be the best fix here.

  • Filed an issue for this now:

    Thanks again for the report! :)

  • I checked a few changes into the master branch that seem to fix this. Tested with sqlite and mysql and the text displays and can be edited correctly. Please check it out if you can and let me know if it gives you any trouble.

  • Thx. :)

    How I can get new version to test it?

    Download zip? or git clone?? I don't know github well. Let's me know.

  • I don't know it is latest version, but download from, and checked.

    I used MySQL.

    It still wrongly display Japanese characters. And Japanese strings saved wrongly.

  • That should be the latest version. Git clone should provide the same thing as well.

    I just realized that the text was coming through encoded as 愛 entities into PHP because the admin page didn't have a character encoding specified. I added a meta tag to the default and admin layouts and it's now sending the Japanese characters through correctly into PHP and rendering them into the page as characters, not as entities.

    That looks like it completes the fix. If you grab the latest copy from the 'Zip' link or by cloning in Git, it should hopefully work for you as well now :)

    Thanks again!

  • Hi jbrodway,

    You are a kind. So I'll help more.;)

    I don't know these came from your correction for a bug I reported...

    At Install :

    Site title, admin name don't accept Japanese.(Or Chinese, Korian....etc. maybe ;))

    At Admin login:

    After logined, show blank page. Back to before page, it show correctly.

    Block : OK, title accept Japanese.

    Blog: OK, title, author and content accept Japanese.

    Designer : Don't work 'Edit' link, show blank page.

    Users: OK, name accept Japanese.

    ML Hirohisa Kawase

  • Thanks for all of these! I was able to fix the site title and admin name using the same changes I used on the other forms. Also just fixed the other issues now as well.

    The Designer edit coming up blank was from a bug introduced when I added support for PHP 5.4's built-in web server, but was easily fixed too.

    Happy holidays! :)

Sign In or Register to comment.