Unsupported Screen Size: The viewport size is too small for the theme to render properly.

Length Of Data With German Umlauts In Utf-8

forums forums SQLyog Using SQLyog Length Of Data With German Umlauts In Utf-8

  • This topic is empty.
Viewing 2 reply threads
  • Author
    Posts
    • #11912
      larsen
      Participant

      Hi,

      I just noticed that MySQL returns the length() of “123ä” as 5 when the field´s character set is utf-8 and returns 4 when the cs is latin1. Of course, I know that some utf-8 chars use 2byte but I find it a little bit confusing nonetheless. I would expect that this string always has a length of 4.

      Is this the intended behaviour or can I change this somehow?

      If you need further info (server variables, etc.) please tell me.

      Lars

    • #30609
      Mahesh
      Member

      This is MySQL question instead SQLyog.

      Length()function Returns the length of the string str, measured in bytes. A multi-byte character counts as multiple bytes. This means that for a string containing five two-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.

      http://dev.mysql.com/doc/refman/4.1/en/string-functions.html#function_length

      In your case :

      select length('123ä');

      Output:

      5

      but for

      select CHAR_LENGTH('123ä');

      Output:

      4

      Because “ä” is a multibyte character.

    • #30610
      larsen
      Participant
      'Mahesh' wrote on '19:

      This is MySQL question instead SQLyog.

      I never said it was a SQLyog question =)

      Quote:
      Length()function Returns the length of the string str, measured in bytes. A multi-byte character counts as multiple bytes. This means that for a string containing five two-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.

      thx! i didn´t knew there was a specific function for that case.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.