We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22098
    • 218 Posts
    Hello,

    we have a MODx installation, and we use no WYSIWYG-editor, just a plain text-field for text-entry. When i enter words with UTF8-karakters, like f.e.:

    één

    the word seems to be encoded in some kind of way before it is entered into the mySQL database. The result is that the output is not correct. When i paste the text directly into the database-content using PHPmyAdmin everything works correctly.

    Our config:

    mySQL5 with latin1-swedish-ci collation on all modx-tables
    mySQL default character set is : UTF-8 Unicode (utf8)

    MODx character encoding is set default to UTF8

    any ideas what’s happening?

    Olaf
      • 10449
      • 956 Posts
      Do you have an example URL?

      Make sure there’s an explicit header in the PHP like:
      header("Content-type: text/html; charset=utf-8");

      because the default charset in PHP is still ISO-8859-1, iirc.
        • 22098
        • 218 Posts
        Quote from: ganeshXL at May 01, 2007, 06:17 AM

        Do you have an example URL?

        Make sure there’s an explicit header in the PHP like:
        header("Content-type: text/html; charset=utf-8");

        because the default charset in PHP is still ISO-8859-1, iirc.

        we’re using AMFPHP for this site, so there is no HTML, we’re using the modx db-API to get the content directly from the database. For the AMFPHP gateway we’re using $gateway->setCharsetHandler( "utf8_decode", "ISO-8859-1", "ISO-8859-1" );

        Olaf
          • 10449
          • 956 Posts
          we’re using AMFPHP for this site, so there is no HTML

          Well, HTML or not: doesn’t matter. Encoding is encoding, whether you output plain text or HTML.

          Did you see this tutorial? http://www.sephiroth.it/tutorials/flashPHP/amfphp_iconv/
          Might help you out with this...
            • 22098
            • 218 Posts
            will take a look into it, tnx!
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: olafmol at May 01, 2007, 05:13 AM

              mySQL5 with latin1-swedish-ci collation on all modx-tables
              mySQL default character set is : UTF-8 Unicode (utf8)

              MODx character encoding is set default to UTF8
              The problem is, if your database content is using latin1_swedish_ci, you have to use latin1 encoding to connect and see the proper character set. Also, check the database charset and collation vs. the table charset and collation to make sure they match. Even if the database charset is UTF8, if you have tables with a collation corresponding to a different charset, you need to set the MODx variable to match the charset for the value in your tables.

              If you are using a release candidate of MODx 0.9.6, change the $modx_connection_charset variable in your manager/includes/config.inc.php to equal ’latin1’. Starting in 0.9.6, MODx now executes a SET CHARACTER SET immediately after connecting to the database; this was to correct issues with certain PHP/MySQL configurations on Windows where PHP was not respecting the character set of the database.
                • 22098
                • 218 Posts
                tnx...the info in the link Ganeshxl provided solved our problem. I installed IconV.dll in PHP, and changed the AMFPHP gatewaysettings to iconv and UTF8 for reading and writing....works like a charm now!

                Olaf