Forums / Bug Reports / [Fixed v1.5.1] PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in...

[Fixed v1.5.1] PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in...

Locked

Started by paulm on 22 Feb 2012, 7:42 PM · Views: 8,337

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
22 Feb 2012, 7:42 PM
#1
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

[Fixed v1.5.1] PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in...

1.5.0 final upgraded from 1.3.6

When updating a products description with special characters the error log shows:

PHP Warning: json_encode() [<a href='function.json-encode'>function.json-encode</a>]: Invalid UTF-8 sequence in argument in /home/domains/elektro.nl/public_html/admin/includes/init_includes/init_admin_history.php on line 34

Not sure if it's related, but I also noticed that all the database tables are latin encoded, except for admin_menus, admin_pages, admin_pages_to_profiles and admin_profiles
(admin_activity_log is encoded latin).

Other than the above error log everything seems to work fine, but I would like to keep the error log clean :smile:

22 Feb 2012, 8:01 PM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,718
Plugin Contributions:
0

Re: [Fixed v1.5.1] PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in...

Paul - I think it was yesterday - but someone else posted about a json_encode problem - turned out to be something with the hosting.

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

22 Feb 2012, 8:21 PM
#3
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: [Fixed v1.5.1] PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in...

Thanks Kim, but I think you mean the post about the Fatal error undefined function: json_encode(), which seems quite a different problem.

In case it's related to the json version, the installed version is 1.2.1

22 Feb 2012, 9:07 PM
#4
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: [Fixed v1.5.1] PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in...

According to the json_encode documentation on php.net:

This function only works with UTF-8 encoded data.

So it seems that the problem is the latin encoding combined with the json_encode function.

Does this mean it's required to convert the database to UTF8 when upgrading to Zen Cart 1.5.0 ? I thought I read somewhere this conversion wasn't required.

22 Feb 2012, 10:30 PM
#5
drbyte avatar

drbyte

Sensei

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

Re: [Fixed v1.5.1] PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in...

I'm unable to replicate the problem you're indicating.

What do I need to do to my installation to trigger your problem?

.
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.

22 Feb 2012, 11:15 PM
#6
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: [Fixed v1.5.1] PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in...

To replicate I think you need a 1.5.0. store with a Latin encoded database (or other non UTF8 encoding), and then update a products description containing a special character.

That's my guess, I haven't tried to replicate it yet.

22 Feb 2012, 11:27 PM
#7
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: [Fixed v1.5.1] PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in...

Forgot to mention that, although it's an upgrade, the admin files are still orginal 1.5.0, except for the language pack (which is Dutch iso).

23 Feb 2012, 12:15 PM
#8
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: [Fixed v1.5.1] PHP Warning: json_encode(): Invalid UTF-8 sequence in argument in...

I have come to the conclusion that this error is not important.

As a quick fix I convert the admin logs to UTF-8. And I will later convert the whole shop to UTF-8, which will prevent problems like this.