I have a string in a field in a MySQL table.
It is VARCHAR, the table encoding is utf8.
The content of the field is one two three
If I run select * from table where content like '%one two%'; the row is returned.
However, if I run update table set content = REPLACE(content, " ", "+;;"); then the result is one two+;;three.
So, what is that first “whitespace” character?
I’m using this table with a Ruby on Rails app. Ruby doesn’t recognize it as a whitespace character either. (e.g. if I split the string on ” “, it doesn’t split on the first space)
Any idea what’s going on?
Thanks.
It’s probably a non breaking space character (2 bytes in UTF8: 0xC2 0xA0). That is not a space, and comparing it with a space will yield false.
You can update your table like so:
Note that you should make sure that the first ‘space’ is actually the character you want to replace.