string-length

MySQL : strange LENGTH() behaviour on utf8 string

偶尔善良 提交于 2021-02-08 12:18:52
问题 I am doing unit tests on requests generators, and I get in trouble with LENGTH function. I have 2 requests that follows each other : SHOW VARIABLES LIKE '%character%' Returns the following result : array(8) { [0] => array(2) { 'Variable_name' => string(20) "character_set_client" 'Value' => string(4) "utf8" } [1] => array(2) { 'Variable_name' => string(24) "character_set_connection" 'Value' => string(4) "utf8" } [2] => array(2) { 'Variable_name' => string(22) "character_set_database" 'Value' =

MySQL : strange LENGTH() behaviour on utf8 string

旧巷老猫 提交于 2021-02-08 12:18:32
问题 I am doing unit tests on requests generators, and I get in trouble with LENGTH function. I have 2 requests that follows each other : SHOW VARIABLES LIKE '%character%' Returns the following result : array(8) { [0] => array(2) { 'Variable_name' => string(20) "character_set_client" 'Value' => string(4) "utf8" } [1] => array(2) { 'Variable_name' => string(24) "character_set_connection" 'Value' => string(4) "utf8" } [2] => array(2) { 'Variable_name' => string(22) "character_set_database" 'Value' =

MySQL : strange LENGTH() behaviour on utf8 string

余生颓废 提交于 2021-02-08 12:18:05
问题 I am doing unit tests on requests generators, and I get in trouble with LENGTH function. I have 2 requests that follows each other : SHOW VARIABLES LIKE '%character%' Returns the following result : array(8) { [0] => array(2) { 'Variable_name' => string(20) "character_set_client" 'Value' => string(4) "utf8" } [1] => array(2) { 'Variable_name' => string(24) "character_set_connection" 'Value' => string(4) "utf8" } [2] => array(2) { 'Variable_name' => string(22) "character_set_database" 'Value' =

Getting the length of a string in SQL

谁说胖子不能爱 提交于 2021-02-05 08:42:19
问题 I'm trying to get the length of a string in SQL (using Firebird version 2.x+). Whenever I select the length of a string it gives me the actual assigned maximum length of that string as opposed to getting the length of how many of the characters are taken in a record, as you can see here: as you can imagine, this does not help me, as I can't order by the length, since I'm trying to order by an attribute that has a constant length assigned. How would I achieve what I am trying to achieve? That

MySQL - select first 10 bytes of a string

混江龙づ霸主 提交于 2021-01-27 21:28:38
问题 Hello wise men & women, How would you select the first x bytes of a string? The use case: I'm optimizing product description texts for upload to Amazon, and Amazon measures field lengths by bytes in utf8 (not latin1 as I stated earlier), not by characters. MySQL on the other hand, seems to operate character-based. (e.g., the function left() is character-based, not byte-based). The difference (using English, French, Spanish & German) is roughly 10%, but it can vary widely. Some tests

TypeError: object of type 'builtin_function_or_method' has no len() while using string

五迷三道 提交于 2020-08-11 11:47:22
问题 I'm pretty sure my program has another stupid mistake, but I can't find it. I've tried to google it for a while, but so far no results. I'm trying to use the len method for a loop. I've used it in exactly the same way in a different function in the program without problems, but in this function I get a TypeError: def longestPalindrome(DNA): """ Finds the longest palindrome in a piece of DNA. """ DNA = DNA.upper #makes sure DNA is in all caps longest = "" for x in range(len(DNA)): for y in

TypeError: object of type 'builtin_function_or_method' has no len() while using string

假装没事ソ 提交于 2020-08-11 11:47:01
问题 I'm pretty sure my program has another stupid mistake, but I can't find it. I've tried to google it for a while, but so far no results. I'm trying to use the len method for a loop. I've used it in exactly the same way in a different function in the program without problems, but in this function I get a TypeError: def longestPalindrome(DNA): """ Finds the longest palindrome in a piece of DNA. """ DNA = DNA.upper #makes sure DNA is in all caps longest = "" for x in range(len(DNA)): for y in