Topic: UTF-8

After this modification i have - any date in datebase in any languages.
A have in datebase - Rusian, English , Latvia - (Аги.(Āģī)) in one string.

Need Export all tables from mysql and  chnage this dump file to UTF-8.
Change in dump file where;  DEFAULT CHARSET=*** COLLATE=**** >-TO-> DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

Make new database with - DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

And import file with you date.

Than install Eny UTF-8 language in FA, Make this dafault. Take language file *.po *.mo from english - convert this files to files with UTF-8 encoding. And put files in you any UTF-8 language in FA.

Notepad++ work great for convert between encodind.

Than change down.


* ..\frontaccount\includes\db\connect_db.inc

function db_query($sql, $err_msg=null)

Add like this

//My change: for UTF-8
  mysql_query("SET NAMES 'utf8';");
  mysql_query("SET CHARACTER SET 'utf8';");
  mysql_query("SET SESSION collation_connection = 'utf8_general_ci';");
//My change: for UTF-8

-----------------
    * ..\frontaccount\includes\ui\ui_input.inc

Change
//htmlentities(strtr($name, array('.'=>'=2E',' '=>'=20','='=>'=3D','['=>'=5B')))......
htmlspecialchars(strtr($name, array('.'=>'=2E',' '=>'=20','='=>'=3D','['=>'=5B'))......

function button($name, $value, $title=false, $icon=false,  $aspect='')
{
    // php silently changes dots,spaces,'[' and characters 128-159
    // to underscore in POST names, to maintain compatibility with register_globals
    $rel = '';
    if ($aspect == 'selector') {
        $rel = " rel='$value'";
        $value = _("Select");
    }
    if (user_graphic_links() && $icon)
    {
        if ($value == _("Delete")) // Helper during implementation
            $icon = ICON_DELETE;
        return "<button type='submit' class='editbutton' name='".
            //htmlentities(strtr($name, array('.'=>'=2E',' '=>'=20','='=>'=3D','['=>'=5B')))
            htmlspecialchars(strtr($name, array('.'=>'=2E',' '=>'=20','='=>'=3D','['=>'=5B')), ENT_COMPAT, $_SESSION['language']->encoding )
            ."' value='1'" . ($title ? " title='$title'":" title='$value'")
            . ($aspect ? " aspect='$aspect'" : '')
            . $rel
            ." />".set_icon($icon)."\n";
    }
    else
        return "<input type='submit' class='editbutton' name='".
            //htmlentities(strtr($name, array('.'=>'=2E',' '=>'=20','='=>'=3D','['=>'=5B')))
            htmlspecialchars(strtr($name, array('.'=>'=2E',' '=>'=20','='=>'=3D','['=>'=5B')), ENT_COMPAT, $_SESSION['language']->encoding )
            ."' value='$value'"
            .($title ? " title='$title'":'')
            . ($aspect ? " aspect='$aspect'" : '')
            . $rel
            ." />\n";
}

---------------

..\frontaccount\inventory\manage\item_units.php

//MY change:       
    //  write_item_unit(htmlentities($selected_id), $_POST['abbr'], $_POST['description'], $_POST['decimals'] );
        write_item_unit(htmlspecialchars($selected_id), $_POST['abbr'], $_POST['description'], $_POST['decimals'], ENT_COMPAT, $_SESSION['language']->encoding );
       
//MY change:
----------------

May be also need config mysql

MySQL server my.cnf or Windows my.ini:   

[client] 

default-character-set= utf8   

[mysql]
collation_server = utf8_unicode_ci

character_set_server = utf8

default-character-set=utf8

init-connect='SET collation_connection = utf8_general_ci'

init-connect='SET NAMES utf8'

[mysqld]

default-character-set=utf8

Re: UTF-8

I have just the following:

MySQL my.cnf file [only a line relevant to UTF-8]:
[mysqld]
default-character-set = utf8


Slovene language [lang/installed_languages.inc] with:
'code' => 'sl_SI',
'name' => 'Slovenš&#269;ina',
'encoding' => 'utf-8',
...


And, I needed just to slightly modify (only 2 lines are added) one FA file (connect_db.inc):

==================================================================

--- includes/db/connect_db.inc.ORIGINAL        2010-12-10 14:12:42.000000000 +0100
+++ includes/db/connect_db.inc            2010-12-14 13:40:11.000000000 +0100
@@ -25,6 +25,7 @@ function set_global_connection($company=
    $connection = $db_connections[$company];

    $db = mysql_connect($connection["host"], $connection["dbuser"], $connection["dbpassword"]);
+        mysql_set_charset('utf8', $db);
        mysql_select_db($connection["dbname"], $db);
    return $db;
}
@@ -169,6 +170,7 @@ function db_create_db($connection)
{
    $db = mysql_connect($connection["host"] ,
        $connection["dbuser"], $connection["dbpassword"]);
+    mysql_set_charset('utf8', $db);
    if (!mysql_select_db($connection["dbname"], $db))
    {
        $sql = "CREATE DATABASE " . $connection["dbname"] . "";

==================================================================

Up to now, everything seems to work OK.

Re: UTF-8

Hi, I have made mentioned changes above and results are OK for static pages but not for the parts retrewes by Ajax JsHttpRequest.
I have modified db_connect file and changed po file to be UTF8 compatible. ages appears with charset=utf8 but ajax shows incorrect characters. Please advise.