These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
how to use Kohana with latin charset keeping utf-8?
  • Hi, i'm really new in using this framework and i'm having a lot of problem developing an application in a different language that is not english...

    First i had to disable the inflector for ORM database because it doesn't work for table names in a different language (always add an s at the end of the table name), now i'm having a lot of problem in visualizing Latin letters like: èéàòìù ecc...

    I tryed changing the locale to iso-8859-1 but it doesn't work and i don't want to use latin charset.

    So how can i do to correctly visualize in utf-8 latin chars in a kohana project?

  • What the..? UTF-8 should support those characters. Are you sure your DB is correctly configured (table/field charset etc.)?

  • Hey @Synchro,

    First i had to disable the inflector for ORM database

    No need. Just override protected $_table_name in your ORM models.

  • First thank you for all the tips. ;) About the utf-8 issue, the database querying is perfect and the echo of a tuple containing special char works. Special chars are not working when inserted "natively" in views as text. example: in the view "test.php" (the text mean "today is monday"):

    oggi è  lunedì
    <?php echo $todaymsgfromdatabase; ?> 
    

    The plain html is visualized wrong, the php from database is ok.

    Do you have any suggestion?

  • I may have the same - or related - problem. Can't compare with 3.3.0 as I didn't use it, but my foreign char handling worked perfectly in 3.2.2 and earlier.

    MySQL db has the correct data - e.g. last name Gorme (that's e acute). Previously displayed correctly throughout. Now (3.3.1) initially displays as Gorm� then disappears completely when passed to another view.

  • Looking through the change log I see some references to utf-8, including one specific to the PDO driver. I am using PDO - should have mentioned it before. I'm going to look at 3.3.0 today.

  • Just found the amendment to the docs regarding PDO configuration. (3.3.0 didn't have the problem, as you would expect.) Synchro, look at Database/Config in your local docs. This amendment is not in the online docs.

  • Thank you for the tip, unfortunately my problem isn't the info taken from database (which is ok) but just the static plain html text that isn't showed properly. :(

  • OK, a little step ahead.. if i set in the bootstrap:

    Kohana::init(array(
        'base_url'  => '/xxxxxxxxxxx/',
        'charset'   => 'iso-8859-1',
        //'charset' => 'utf-8',
    ));
    

    The static visualization of my pages are ok but obviously (as the database is in utf-8, the data does not render right).

    Why if i set in bootstrap and database config utf-8 charset the static and dynamic data are not shown with the same charset?

  • I think I recall a similar problem I had many years ago, totally non-Kohana related. Could you please check which charset your files are being saved to? I develop my applications in geany, but even notepad allows for different charsets when you save the file... If you want the text to be rendered correctly, then your files should be encoded in UTF-8.

    And of course, I presume your webserver is configured to use UTF-8...?

  • Furter step ahead, used:

            'charset'      => 'latin1',
    

    in database.php config file.

    now my website is in iso-8859-1... i preferred it would be in utf8 but it does not works so that's it. In this way it works well i think for all occidental chars.

  • Just for info, i'm using zend studio as editor with utf-8 charset. Server apache on windows machine.

Howdy, Stranger!

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

In this Discussion