I am inserting users from drupal6 to drupal7 using a custom script. I am using db_insert function. In one of the D6 entry I am getting ® mark in a field and because of this that particular value become blank in D7 database. D6: imatter® -> D7:

Anyone has any idea about how to insert this value in database?

Collation is same in both database: utf8_general_ci And in phpmyadmin its look like same as above, means no html code for ®

  • what is your query statement?
    – Yuseferi
    Commented Feb 20, 2014 at 6:54

2 Answers 2


In the case that your insertion script is not capable of handling UTF-8 encoding (it sounds like this is the case), you can get around this by inserting this character as 7-bit HTML entities (i.e. ® or ®) provided the field where it appears is going to be rendered as HTML (and not as plain text). Just do a search and replace and replace all occurences of ® with ® in the source text file.

If this workaround doesn't work (because the field is supposed to be plain text, or for some other reason), you must do two things:

  1. Make sure your file containing these characters is UTF-8 (not ISO-8859-1 or some other encoding incompatible with UTF-8).

  2. Make sure your insertion script is capable of handling UTF-8 (db_insert is, but I don't know what other components you use).


Try utf8_encode before store you variable

$newusername =  utf8_encode($username);

or Drupali method

$newusername =   drupal_convert_to_utf8($username,'utf-8');
  • @GisleHannemyr,tnx, I update my answer
    – Yuseferi
    Commented Feb 20, 2014 at 7:11
  • Your first suggestion (call to PHP utf8_encode) will only work if the source file is in ISO-8859-1 encoding. Re: utf8_encode Yes, it may work, or it may not, depending on the the source data format. Your second suggestion (call Drupal API drupal_convert_to_utf8) is a no-op, and will not work here. Commented Feb 20, 2014 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.