We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 54358
    • 26 Posts
    Hi,
    I've read multiple places now that it's recomended using the "utf8_unicode_ci" database collation. But I chose "latin1_danish_ci" when I made my databse (and during the install of ModX) because the main language of the site is Danish. I'm wondering now, though, whether or not that was a smart choice.

    Will it cause problems to have a different collation that the recomended? And if yes, can I just change that in the database or is there a setting in the manager somewhere too? Or am I just doomed?

    This question has been answered by BobRay. See the first response.

      • 46886
      • 1,154 Posts
      Well the issue is what the other language will be. If its French for example you could have problems. If its English then no problem
      • discuss.answer
        • 3749
        • 24,544 Posts
        Changing it in the database is a little more complicated than you would think. First, there is the collation of the database, then there is the collation of each table, finally, there is the collation of the individual text fields in the DB. You can see all that if you look at the Structure tab in PhpMyAdmin.

        In addition, if you change the character set as well, you have to deal with the fact that the data in the DB is in one character set, but you've specified it as being in another character set.

        There's some more info here: https://bobsguides.com/convert-db-utf8.html, though I suspect that you wouldn't need to go through all that just to change the collation.

        Ultimately, you want the character set in the DB to match what's in config.inc.php and any character set specified in all templates.

        For the collation, I think just changing it everywhere in the DB would be enough, as long as the collation you pick goes with the character set. The collation is mainly just to prevent sorting errors caused by any accented characters when you alphabetize things (e.g., the order of elements and usernames in the Manager, or alphabetized lists in the front end).

        That said, when I install MODX, I usually create the DB manually first and set the DB character set to utf8 / utf8mb4_general_ci. I would use utf8mb4_unicode_ci if the site was not in English. General is a little faster than unicode, but less accurate for words with accented letters.

        FYI, the current recommendation for collations is utf8mb4_unicode_ci or utf8mb4_general_ci. See the accepted answer here: https://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci. I think that would be safe for you to use if you're just changing the collation, but I could be wrong.

        Whatever you do, I'd recommend backing up the site first.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
        • If you want to use emojis, you need utf8mb4. That's what convinced me. tongue
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.