-
1. Re: Incorrect string value
BKBK May 14, 2014 2:29 AM (in response to happysailingdude)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")>
-
2. Re: Incorrect string value
happysailingdude May 26, 2014 3:26 AM (in response to BKBK)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
-
3. Re: Incorrect string value
BKBK May 26, 2014 12:11 PM (in response to happysailingdude)You could filter out the characters as I suggested, before storing the string in the database.
-
4. Re: Incorrect string value
happysailingdude May 29, 2014 5:46 AM (in response to BKBK)Thanks Dan - yes that was what I was hoping to do (filter out the characters before inserting to the db). I'm just trying to find the most efficient way to remove those characters; I had been using safetext.cfm but that seems a bit out of date now.. http://www.cflib.org/udf/SafeText
It'd be great if there was an inbuilt cf function like RemoveOddCharacters() for use on strings before inserting them into dbs - maybe there is one.. anyone?
Thanks
Nick
-
5. Re: Incorrect string value
BKBK May 29, 2014 6:22 AM (in response to happysailingdude)I suggested one, single line for the job: <cfset myString = replace(myString,chr(8203),"","all")>
-
6. Re: Incorrect string value
happysailingdude May 29, 2014 6:34 AM (in response to BKBK)Hi again - yes I know but that only removes that one particular special character; I believe there are quite a few that cause problems if stored in the db. I'm wondering if there is a function that removes all the various troublesome special characters in one go. Failing that I wonder if there is a list of all these characters that i can loop through (using the replace as you say)?..
-
7. Re: Incorrect string value
BKBK May 29, 2014 6:49 AM (in response to happysailingdude)There are thousands of special characters, and infinitely many combinations of them. To be practical and efficient, therefore, you have to focus on removing just the ones that are troublesome.
-
8. Re: Incorrect string value
happysailingdude Jun 9, 2014 7:19 AM (in response to happysailingdude)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
-
9. Re: Incorrect string value
BKBK Jun 9, 2014 7:24 AM (in response to happysailingdude)Your link broke.
-
10. Re: Incorrect string value
happysailingdude Jun 9, 2014 7:34 AM (in response to BKBK)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..
-
11. Re: Incorrect string value
BKBK Jun 9, 2014 7:40 AM (in response to happysailingdude)It is unauthorized.
-
12. Re: Incorrect string value
happysailingdude Jun 9, 2014 8:20 AM (in response to BKBK)How is it now? just got an email to say post has gone live
-
13. Re: Incorrect string value
BKBK Jun 9, 2014 10:27 AM (in response to happysailingdude)It is now available.
-
14. Re: Incorrect string value
BKBK Jun 9, 2014 11:05 AM (in response to happysailingdude)I have answered your question in your other thread.
-
15. Re: Incorrect string value
happysailingdude Jul 1, 2014 2:04 AM (in response to happysailingdude)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.
-
16. Re: Incorrect string value
BKBK Jul 1, 2014 4:00 AM (in response to happysailingdude)Thanks. Good to know. Please mark it as the correct answer.

