Unable to save term "Big Honor for Branford's Le Petit Café" I was trying to save term with name "Big Honor for Branford's Le Petit Café" using taxonomy_term_save function which throws me the following error

PDOException: in drupal_write_record() in common.inc 


Is it some thing related to character encoding  ? should i have to convert the character? I am not sure how to do that.

Please find the code that throws the error,

$term_name  = new stdClass();
$term_name-&gt;name = urldecode("Big%20Honor%20for%20Branford%27s%20Le%20Petit%20Caf%E9");
$term_name-&gt;vid = 1;
taxonomy_term_save($term_name);


If we are using the exact "Big Honor for Branford's Le Petit Café" is a file then i could not get the error but, when url encoded and decoded again, we will have the same character set.
This code works perfectly for me:

$term = (object)array(
  'name' =&gt; "Big Honor for Branford's Le Petit Café",
  'vid' =&gt; 1
);

taxonomy_term_save($term);


No errors, and the term is saved as expected. So it looks like the issue is something to do with your server configuration. Without more details it's impossible to say what that problem might be though.

UPDATE

Turns out this a multibyte encoding issue. Wrapping the string in utf8_encode() will fix it:

$term_name-&gt;name = utf8_encode(urldecode("Big%20Honor%20for%20Branford%27s%20Le%20Petit%20Caf%E9"));