Skip to main content
Inspiring
May 12, 2014
Question

Incorrect string value

  • May 12, 2014
  • 3 replies
  • 4655 views

Hi - we've just upgraded from cf8 to cf9 and are getting a fair few of these errors - "Error Executing Database Query. Incorrect string value: '\xE2\x80\x8BWe ...' for column" as we try to insert a row in the db.

The query is inserting the following string "We are seeking a" - nothing innocuous in the text and certainly no instance of this string '\xE2\x80\x8B' (despite what the error message says).

Has anyone else run into this, any ideas what's going on?

Thanks very much for any help you can offer as I'm completely stuck.

Thank you.

Kind regards,

Nick

This topic has been closed for replies.

3 replies

Nick WayAuthor
Inspiring
July 1, 2014

turns out the issue was the charset in db was set to latin_sweedish

i changed it to utf8_general_ci and that sorted it.

there was one additional twist to this which i solved by looking here MySQL Bugs: #33475: Incorrect string value when inserting unicode codepoint \xC2\x92

the key part being at the bottom "

[9 Dec 2011 0:07] Arkadiy Kulev

This problem solves easily. Don't forget to not only set the database, table and collation to utf8, BUT THE COLUMNS ALSO!

That's what cause the problem for me. I created the table in latin, then switch to utf8, but forgot to also change the columns."

that caught me out but got there in the end.

HTH anyone else who has this.

BKBK
Community Expert
Community Expert
July 1, 2014

Thanks. Good to know. Please mark it as the correct answer.

Nick WayAuthor
Inspiring
June 9, 2014

FYR I am hoping that this How to turn this Java into something I can use in CF? will eventually provide anyone who's interested with a way to remove special characters from a string before inserting in the db

BKBK
Community Expert
Community Expert
June 9, 2014

Your link broke.

Nick WayAuthor
Inspiring
June 9, 2014

Thanks Dan - seems ok from my end, think that's because it's a post I've put in here (getting started forum) that hasn't yet been approved for publication by the moderators - hopefully link will work shortly..

BKBK
Community Expert
Community Expert
May 14, 2014

The Hex value 0xE2 0x80 0x8B is the representation in UTF-8 of the 'zero-width space' character. You may remove it from the string - for example, by replacing it with a blank space - before the string enters the query.

Assuming that chr(8203) represents the zero-width character, you could replace it as follows:

<cfset myString = replace(myString,chr(8203),"","all")>

Nick WayAuthor
Inspiring
May 26, 2014

Thanks Dan.

Is there an inbuilt cf function I can use to strip out any weird characters like that do you happen to know? Or alternatively maybe I need to tell my database (mysql) not to be so fussy and accept those chrs?

Hope you're well - thanks for the help, much appreciated.

Nick

BKBK
Community Expert
Community Expert
May 26, 2014

You could filter out the characters as I suggested, before storing the string in the database.