1

I've got a SQL operation with the word "şalom" which contains a non-ASCII character. And the statement ( which I posted below ) runs totally fine:

UPDATE `myTable1` SET `description`='The topic for this learning plan starts with the \"ÅŸ\" ( sh ) letter which is a non-ASCII char. ', `topic`='ÅŸalom'' WHERE `RecID` = '1308'"

however, right after this statement, I have to run another one to put the word "şalom" in another table but that one FAILS. The reported error is follows:

INSERT INTO `myTable2` (`TOPIC_Name`, `TOPIC_AddedOn`) VALUES ('[Åÿalom]', '2018-04-12'). 

LAST SQL ERROR:

HY000, 1366, Incorrect string value: '\xC5\xFFalom...' for column 'Topic_Name' at row 1

We've checked the table structures and the field structures and saw that they are identical and designed to accept utf-8.

We cannot figure out why one statement passes but the other one chokes. Any ideas?

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
Average Joe
  • 4,521
  • 9
  • 53
  • 81
  • Erm... 0xc5 0xff isn't valid UTF-8... – Ignacio Vazquez-Abrams Apr 13 '18 at 03:51
  • I realize that but if you check the "insert into", i'm using "[Åÿalom]" in the statement. I have no idea where & how I end up with "\xC5\xFFalom". I do not have control over that. And that IS the the problem, I think. – Average Joe Apr 13 '18 at 04:04
  • Did you tell the connection which charset you want to use? – Ignacio Vazquez-Abrams Apr 13 '18 at 04:04
  • I do not think I did but if there was something up with that wouldn't the "update" statement which runs in the earlier operation also fail? – Average Joe Apr 13 '18 at 04:07
  • 1
    You may need to `SET NAMES UTF8` https://stackoverflow.com/questions/202205/how-to-make-mysql-handle-utf-8-properly – Joe Phillips Apr 13 '18 at 04:08
  • Also, I just run the same statement in phpmyadmin against that database as follows: INSERT INTO `sc_topics` (`TOPIC_Name`, `TOPIC_AddedOn`) VALUES ('şalom]', '2018-04-12') And it just went thru. It's even more puzzling now. why is it in PHP EZ-SQL fails at this? – Average Joe Apr 13 '18 at 04:29

1 Answers1

0

ÅŸ is Mojibake for ş. When treated as latin1, ÅŸ is hex C5FF. See Trouble with UTF-8 characters; what I see is not what I stored for discussion of "Best practice" and "Mojibake".

Rick James
  • 135,179
  • 13
  • 127
  • 222