Zen Cart Logo
Forums / Addon Language Packs / UTF-8 Zen-Cart Tutorial for v1.3.x

UTF-8 Zen-Cart Tutorial for v1.3.x

Views: 77,326

Results 101 to 120 of 145
19 Nov 2010, 1:01 AM
#101
fjcv avatar

fjcv

New Zenner

Join Date:
Nov 2010
Posts:
6
Plugin Contributions:
0

UTF-8 Zen-Cart Tutorial for v1.3.x

Hi everyone!

I was removing all the countries I did not need from the countries and changed Spain to España so everything would be in spanish on my sitea fter that started to get a question mark symbol for the Ñ character in the registration form drop-down.

So I followed this steps to solve it:

  1. I inserted España in the database, which lead me to an error in the purchase confirmation email, it displayed the ñ when inserting the country, but solved the registration form issue.

  2. I deleted España from the countries table and added it again after changing the encoding of countries_name database field, and inserted it again.

  3. I tried changing the encoding of the field to utf8_spanish_ci

  4. Changed the whole database to UTF-8 from COLLATE in phpMyAdmin

  5. I´ve created the file my_db_charset.php in /includes/extra_configures and also in admin/includes/extra_configures

  6. I downloaded the database to my pc and using UltraEdit I changed all instance of latin1 to utf8, and utf8_latin_ci to utf8_spanish_ci

The rest of special characters in my site are displayed correctly. None of the above helped me....

The site is https://www.touchtoys.es and I´m running ZenCart 1.3.9d with a template from zencart-template

I´m stating to go crazy due to this error, any ideas where I might messed up or what am I missing?

Thanks for everything!

19 Nov 2010, 10:48 AM
#102
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,875
Plugin Contributions:
7

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

  1. I´ve created the file my_db_charset.php in /includes/extra_configures and also in admin/includes/extra_configures

How does España display in the country list in admin?

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

19 Nov 2010, 10:59 AM
#103
fjcv avatar

fjcv

New Zenner

Join Date:
Nov 2010
Posts:
6
Plugin Contributions:
0

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

THANK YOU VERY MUCH TORVISTA!!!

I checked it in the country list, which was displayed with the same odd character. So I changed it there and solved the problem!

I own you a couple of beers and some tapas!!!

19 Nov 2010, 11:06 AM
#104
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,875
Plugin Contributions:
7

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

Point 6 was the key to ensure the character entered in admin got stored in the database as UTF-8.
You should delete or fix the accents on these two provinces too or you will not be able to check your validation.

[QUOTE
theForm.zone_id.options[2] = new Option("K�rnten", "99");

theForm.zone_id.options[1] = new Option("Baden W�rtemberg", "80");

[/QUOTE]

Nice site!

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

29 Nov 2010, 12:07 AM
#105
fjcv avatar

fjcv

New Zenner

Join Date:
Nov 2010
Posts:
6
Plugin Contributions:
0

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

I just left three countries since we do not want to expand worldwide just now ;-)

Do I have to chance that as well? and where do I change that lines?

Thanks again for everything!

9 Dec 2010, 3:53 PM
#106
damiantaylor avatar

damiantaylor

Zen Follower

Join Date:
Aug 2009
Posts:
244
Plugin Contributions:
0

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

Hi, I'm looking for some advice regarding my tables.

I've converted my database as per the tutorial.
Now, when I create new tables in my databse, they use utf8_general_ci collation.
My existing tables (the ones created when I installed Zen Cart) are still showing latin1_swedish_ci.

Does this matter?
Should I convert the latin ones to utf8?
I tested converting 1 table from latin to utf8 and it doesn't seem to have broken anything but I did notice the columns in the table are still latin. I can convert the columns to utf-8 too if I need to.

I'd like to get everything to utf-8 but I don't know if doing it would break my cart?

Any advice would be appreciated guys

12 Dec 2010, 12:38 AM
#107
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

As for the tables and the overall database, if you change those settings then it will ensure that new columns added to those tables or new tables added to that database will use the new character set.

Converting the columns is what's important for your data, but if you do that without protecting the data inside those columns, you'll end up with corrupted data.

I'm not sure which tutorial you're talking about. There are about 10 different ideas tossed around in this thread by various people, with varying degrees of accuracy.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Dec 2010, 6:08 PM
#108
damiantaylor avatar

damiantaylor

Zen Follower

Join Date:
Aug 2009
Posts:
244
Plugin Contributions:
0

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

Thanks for the reply Dr Byte.
The tutorial I was referring to was the original one, in post #1.

I'm worried about corrupting data by converting tables so I may start by converting a couple of small tables and wait for a week or two and if there are no problems, do another couple of tables.
It will take a while but hopefully I won't screw anything up!

If you have any better ideas I'm all ears :)

Thanks again for your help

9 Feb 2011, 12:32 AM
#109
25rosas avatar

25rosas

New Zenner

Join Date:
Jan 2011
Posts:
3
Plugin Contributions:
0

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

The help here worked great for me.
I've installed v1.3.9h like two weeks ago, the tutorial worked great to get Spanish language running.
Two small notes: Database was allready utf8 collation; also, query_factory.php comes with some logic to assign tf8, so no need to make this change:
//BOF changed for utf-8
mysql_query('SET NAMES "utf8"', $this->link);
//EOF changed for utf-8.


Aside from that, to beginners like me I recommend making sure you work one language at a time, one file at a time -making a safe coopy of your original file-.


Finally, using View | Character Encoding to make sure you're encoding right from the start, was of great help to me.

Thank you so much !!

Carlos

16 Feb 2011, 4:11 PM
#110
timtimd avatar

timtimd

New Zenner

Join Date:
Feb 2011
Posts:
1
Plugin Contributions:
0

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

Using the latest version of Zen Cart having updated from a previous version I ahve added French, German and Spanish. All works well except Spanish. However using the my_DB_charset setting to utf8 the Spanish is working OK.

Is it possible to introduce an if statement to the PHP file my_db_charset to just use the utf8 setting for Spanish ???

Yes I am new to this :lookaroun

17 Feb 2011, 3:42 AM
#111
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

timtimd:

Is it possible to introduce an if statement to the PHP file my_db_charset to just use the utf8 setting for Spanish ???
No, because it doesn't know the selected language until long after the database connection is established.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

17 Feb 2011, 12:30 PM
#112
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,875
Plugin Contributions:
7

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

Having my spanish pack in utf-8 seems to be causing more harm than good for new users.
I have looked for and failed to find a free text batch converter to create a 8859 version from the utf8 files. Can anyone help to do this as a one off?
I don't mind maintaining the two versions but I just don't have the time to create this.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

9 Mar 2011, 8:37 PM
#113
vinhbao avatar

vinhbao

New Zenner

Join Date:
Mar 2011
Posts:
7
Plugin Contributions:
0

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

i have read & followed the tutorial at https://www.srw2d.com regarding UTF-8... however, i'm having a problem. even though i go in and set the utf8_general_ci in the database, after I install all the fields/tables are set to latin1_general_ci.

any ideas?

14 Mar 2011, 4:14 AM
#114
cjcraven avatar

cjcraven

Zen Follower

Join Date:
Aug 2004
Location:
Osaka Japan
Posts:
149
Plugin Contributions:
0

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

vinhbao:

i have read & followed the tutorial at https://www.srw2d.com regarding UTF-8... however, i'm having a problem. even though i go in and set the utf8_general_ci in the database, after I install all the fields/tables are set to latin1_general_ci.

any ideas?

PHP5
ZenCart 1.3.9h

I have same issue here. Also adding the my_db_charset.php files to the extra_confirgures folders in admin and the store results in blank store and admin pages, deleting the files restores the pages. The encoding of these pages is Shift JIS not the expected UTF-8.

Craig

14 Mar 2011, 4:27 AM
#115
cjcraven avatar

cjcraven

Zen Follower

Join Date:
Aug 2004
Location:
Osaka Japan
Posts:
149
Plugin Contributions:
0

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

PHP5
Zen 1.3.9h
Upgrading from Zen 1.2 (Japanese)

Shaun Ward, thank you so much for your help. I installed the Japanese Zen Cart 1.3.02-|10n-jp-6 with unsatisfactory results as it is based on an older version.

I am editing admin/index.php file as per your instructions. I do not know PHP very well and unfortunately stumble a lot. After making the changes the site gives me an error statement;

Parse error: syntax error, unexpected $end in store/zc_admin/index.php on line 189

Br Craig

14 Mar 2011, 4:51 AM
#116
cjcraven avatar

cjcraven

Zen Follower

Join Date:
Aug 2004
Location:
Osaka Japan
Posts:
149
Plugin Contributions:
0

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

Please note the Japanese Language Pack that Shaun made already has the correct admin/index.php and invoice.php files.

Sorry for the unnecessary post.

1 Jun 2011, 6:37 PM
#117
divinelighting avatar

divinelighting

Zen Follower

Join Date:
Jun 2006
Location:
Atlanta, GA
Posts:
124
Plugin Contributions:
0

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

Using 1.3.9h, changing from latin1_swedish to utf8_general

In addition to defining charset as indicated here:
http://www.zen-cart.com/forum/showthread.php?t=153582

This is the most functional script I have found for converting tables and table data:

<?php

function MysqlError()
{
        if (mysql_errno())
        {
                echo "<b>Mysql Error: " . mysql_error() . "</b>\n";
        }
}

$username = "root";
$password = "";
$db = "database";
$host = "localhost";

$target_charset = "utf8";
$target_collate = "utf8_general_ci";

echo "<pre>";

$conn = mysql_connect($host, $username, $password);
mysql_select_db($db, $conn);

$tabs = array();
$res = mysql_query("SHOW TABLES");
MysqlError();
while (($row = mysql_fetch_row($res)) != null)
{
        $tabs[] = $row[0];
}

// now, fix tables
foreach ($tabs as $tab)
{
        $res = mysql_query("show index from {$tab}");
        MysqlError();
        $indicies = array();

        while (($row = mysql_fetch_array($res)) != null)
        {
                if ($row[2] != "PRIMARY")
                {
                        $indicies[] = array("name" => $row[2], "unique" => !($row[1] == "1"), "col" => $row[4]);
                        mysql_query("ALTER TABLE {$tab} DROP INDEX {$row[2]}");
                        MysqlError();
                        echo "Dropped index {$row[2]}. Unique: {$row[1]}\n";
                }
        }

        $res = mysql_query("DESCRIBE {$tab}");
        MysqlError();
        while (($row = mysql_fetch_array($res)) != null)
        {
                $name = $row[0];
                $type = $row[1];
                $set = false;
                if (preg_match("/^varchar\((\d+)\)$/i", $type, $mat))
                {
                        $size = $mat[1];
                        mysql_query("ALTER TABLE {$tab} MODIFY {$name} VARBINARY({$size})");
                        MysqlError();
                        mysql_query("ALTER TABLE {$tab} MODIFY {$name} VARCHAR({$size}) CHARACTER SET {$target_charset}");
                        MysqlError();
                        $set = true;

                        echo "Altered field {$name} on {$tab} from type {$type}\n";
                }
                else if (!strcasecmp($type, "CHAR"))
                {
                        mysql_query("ALTER TABLE {$tab} MODIFY {$name} BINARY(1)");
                        MysqlError();
                        mysql_query("ALTER TABLE {$tab} MODIFY {$name} VARCHAR(1) CHARACTER SET {$target_charset}");
                        MysqlError();
                        $set = true;

                        echo "Altered field {$name} on {$tab} from type {$type}\n";
                }
                else if (!strcasecmp($type, "TINYTEXT"))
                {
                        mysql_query("ALTER TABLE {$tab} MODIFY {$name} TINYBLOB");
                        MysqlError();
                        mysql_query("ALTER TABLE {$tab} MODIFY {$name} TINYTEXT CHARACTER SET {$target_charset}");
                        MysqlError();
                        $set = true;

                        echo "Altered field {$name} on {$tab} from type {$type}\n";
                }
                else if (!strcasecmp($type, "MEDIUMTEXT"))
                {
                        mysql_query("ALTER TABLE {$tab} MODIFY {$name} MEDIUMBLOB");
                        MysqlError();
                        mysql_query("ALTER TABLE {$tab} MODIFY {$name} MEDIUMTEXT CHARACTER SET {$target_charset}");
                        MysqlError();
                        $set = true;

                        echo "Altered field {$name} on {$tab} from type {$type}\n";
                }
                else if (!strcasecmp($type, "LONGTEXT"))
                {
                        mysql_query("ALTER TABLE {$tab} MODIFY {$name} LONGBLOB");
                        MysqlError();
                        mysql_query("ALTER TABLE {$tab} MODIFY {$name} LONGTEXT CHARACTER SET {$target_charset}");
                        MysqlError();
                        $set = true;

                        echo "Altered field {$name} on {$tab} from type {$type}\n";
                }
                else if (!strcasecmp($type, "TEXT"))
                {
                        mysql_query("ALTER TABLE {$tab} MODIFY {$name} BLOB");
                        MysqlError();
                        mysql_query("ALTER TABLE {$tab} MODIFY {$name} TEXT CHARACTER SET {$target_charset}");
                        MysqlError();
                        $set = true;

                        echo "Altered field {$name} on {$tab} from type {$type}\n";
                }

                if ($set)
                        mysql_query("ALTER TABLE {$tab} MODIFY {$name} COLLATE {$target_collate}");
        }

        // re-build indicies..
        foreach ($indicies as $index)
        {
                if ($index["unique"])
                {
                        mysql_query("CREATE UNIQUE INDEX {$index["name"]} ON {$tab} ({$index["col"]})");
                        MysqlError();
                }
                else
                {
                        mysql_query("CREATE INDEX {$index["name"]} ON {$tab} ({$index["col"]})");
                        MysqlError();
                }

                echo "Created index {$index["name"]} on {$tab}. Unique: {$index["unique"]}\n";
        }

        // set default collate
        mysql_query("ALTER TABLE {$tab}  DEFAULT CHARACTER SET {$target_charset} COLLATE {$target_collate}");
}

// set database charset
mysql_query("ALTER DATABASE {$db} DEFAULT CHARACTER SET {$target_charset} COLLATE {$target_collate}");

mysql_close($conn);
echo "</pre>";

On my test database, it works almost flawlessly. However, I get a few errors. For example:

Dropped index idx_status_group_zen. Unique: 1
Mysql Error: Can't DROP 'idx_status_group_zen'; check that column/key exists
Dropped index idx_status_group_zen. Unique: 1
Dropped index idx_expires_date_zen. Unique: 1
Dropped index idx_date_scheduled_zen. Unique: 1
Altered field banners_title on banners from type varchar(64)
Altered field banners_url on banners from type varchar(255)
Altered field banners_image on banners from type varchar(64)
Altered field banners_group on banners from type varchar(15)
Altered field banners_html_text on banners from type text
Created index idx_status_group_zen on banners. Unique:
Mysql Error: Duplicate key name 'idx_status_group_zen'
Created index idx_status_group_zen on banners. Unique:

Dropped index idx_key_value_zen. Unique: 1
Mysql Error: Can't DROP 'idx_key_value_zen'; check that column/key exists
Dropped index idx_key_value_zen. Unique: 1
Dropped index idx_cfg_grp_id_zen. Unique: 1
Altered field configuration_title on configuration from type text
Altered field configuration_key on configuration from type varchar(255)
Altered field configuration_value on configuration from type mediumtext
Altered field configuration_description on configuration from type text
Altered field use_function on configuration from type text
Altered field set_function on configuration from type text
Created index unq_config_key_zen on configuration. Unique: 1
Created index idx_key_value_zen on configuration. Unique:
Mysql Error: BLOB/TEXT column 'configuration_value' used in key specification without a key length
Created index idx_key_value_zen on configuration. Unique:

Are these pre-existing errors or is there a problem with the script?

http://www.divinelighting.com -- Super Orders 3.0 -- Ultimate SEO -- Quantity Discounts -- SitemapXML -- Image Handler -- Shipworks

2 Jun 2011, 6:13 AM
#118
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

Those are script errors. As written it's not capable of handling multi-key indexes nor partial-length indexes, hence the error messages you're seeing.

What's the source of that script? Where did you get it from? It appears as though its source is:
stackoverflow.com/questions/105572/a-script-to-change-all-tables-and-fields-to-the-utf-8-bin-collation-in-mysql
but I'm just wondering if you're citing another source.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

2 Jun 2011, 1:17 PM
#119
divinelighting avatar

divinelighting

Zen Follower

Join Date:
Jun 2006
Location:
Atlanta, GA
Posts:
124
Plugin Contributions:
0

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

Yes Dr. Byte, that is exactly where it came from. Are you aware of a script that will handle all the indexes?

http://www.divinelighting.com -- Super Orders 3.0 -- Ultimate SEO -- Quantity Discounts -- SitemapXML -- Image Handler -- Shipworks

3 Jun 2011, 12:29 AM
#120
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: UTF-8 Zen-Cart Tutorial for v1.3.x

I agree -- that script was probably the closest I've seen to reliably handling most of the steps involved in properly preserving data while converting character sets and collation to UTF8.

I've made some alterations to overcome several of the limitations I see in it, and contributed the result here:
http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=1937

NOTES:
MAKE A DATABASE BACKUP FIRST!
And take your store Down For Maintenance while converting.
Watch out for any warnings - they will be shown in bold. Every error should receive appropriate attention before putting your site back online.

Feedback welcome.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.