-1

is there a difference between mysql server and python count the length of a utf string

while working with Japanese language, strings length are different in mysql length and python len(). e.g len("こんにちは") in python returns 5 enter image description here

while select lenght("15") in Mysql returns 15 .

enter image description here

does it have anything to do with how they interpret unicode ? is there there any other information i should mention like engine's uft version or the OS's?

pppery
  • 3,731
  • 22
  • 33
  • 46
Max
  • 4,152
  • 4
  • 36
  • 52
  • Solution: Use `CHAR_LENGTH()`, which counts characters. – Tim Biegeleisen Aug 13 '23 at 13:32
  • `select lenght("15")` is wrong in 3 ways: 1.) the function is named LENG**TH**, 2.) text literals need apostrophes (`'`) instead of quotation marks (`"`), and 3.) `length( '15' )` would in no way return `15`. Also it`s U**TF** (instead of u**ft**). How can one make so many mistakes in so little text? Reconsider your level of attention for details. Also it's **P**ython, My**SQL** and **U**nicode. – AmigoJack Aug 13 '23 at 13:48

0 Answers0