Databases: textlib::convert fails on international characters

Databases: textlib::convert fails on international characters

by Tom Durocher -
Number of replies: 1

Moodle 2.2.3 and Drupal 7.14

I am using a Drupal database for external authentication, registration and single sign-on. Everything is working fine until I discovered that people with names like Brückner and cities like Lamboréné had their data cut short when it is transferred to their Moodle profiles on login (i.e., Br and Lambor). It looks fine in Drupal profile, the database tables are both utf8 encoded and collated. Looks fine in the Drupal database.

The Drupal tables are utf8_general_ci and the Moodle tables are utf8_unicode_ci, but changing either one did not change the issue. iconv in textlib::convert cuts the string off and gives an error of "Notice: iconv() [function.iconv]: Detected an incomplete multibyte character in input string in /.../moodle/lib/textlib.class.php on line 172". The input and output encoding for convert is both UTF-8. Maybe the input encoding should be something different but I don't know what. Like I said, looks like everything already is UTF-8 and the intl chars look fine on Drupal (they do elsewhere on Moodle as well).

Thanks for any help. I've tried pretty hard to figure out why this might be but all the configuration of PHP and MySQL looks correct as far as I can tell. Haven't yet figured out how to look at the raw data in the PHP environment, even with Netbeans debugger.

Average of ratings: -
In reply to Tom Durocher

Re: Databases: textlib::convert fails on international characters

by Tom Durocher -

To answer my own question for anybody's benefit: the "notice" coming from iconv tells us that the fields coming from the Drupal db are NOT utf8, despite the database being set up that way and showing international characters just fine in phpmyadmin and the Drupal UI. So, the solution was to run each field through the php function utf8_encode after getting it out of Drupal and before putting it into the Moodle db.