Q: $SITE_INFO['database_charset'] setting.

Post

Posted
Rating:
#5520 (In Topic #1283)
Avatar
Standard member
ironfeather is in the usergroup ‘Well-settled’

utf-8 vs. utf8

Hello,

In the _config.php:

I had set:
$SITE_INFO['database_charset'] = 'utf-8';

and my site works great, the english & japanese display as needed….

I then was attempting to install the ecommerce addon and it errors out unable to create the new tables due to not recognizing utf-8…. to fix this I changed the $SITE_INFO['database_charset'] = 'utf8';  and now ecommerce installs and works fine…

but… now my japanese text is all scrambled….  to fix this I changed back to
$SITE_INFO['database_charset'] = 'utf-8';
Now my Japanese texts display properly…

utf-8 vs. utf8

Maybe I should have left that setting blank as suggested…. but wanted to share this experience.


———–
Publisher of IronFeather Journal since 1987.  Host of KGNU Colorado Radio for 20 years. 
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido:  Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : 
http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp

 
Online now: No Back to the top

Post

Posted
Rating:
#5524
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Ah right.

This is a subtle thing.

ISO standards says it is written "utf-8". MySQL says it is written "utf8".

When you have the setting at "utf-8" MySQL is ignoring it in terms of how it is communicating with your database. However, it is not when it is creating tables - it tries to create the tables with it, which will fail.

Likely your database tables are actually in latin1 (hence why things mess up when you set it to "utf8"), I assume because you upgraded from ocPortal 9. We switched to utf-8 with Composr 10.

The best fix is to export the database to an SQL dump, then in a text editor do a string replace of latin1 to utf8. Then reimport it. Then remove the database_charset setting.

Hopefully that works for you. Charsets are confusing, my advice may not be quite right depending on what exact tools you use. Essentially you should ensure your .sql file looks correct in Japanese in your text editor, and is saved as utf-8 encoding in the text editor. If that's the case, it should be good.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Forum statistics:
  • 2,052 topics, 7,195 posts, 10,827 members
  • Our newest member is LowfareMart
Birthdays:
Back to Top