{"id":2682,"date":"2020-12-31T10:51:44","date_gmt":"2020-12-31T02:51:44","guid":{"rendered":"https:\/\/www.gbase8.cn\/?p=2682"},"modified":"2020-12-31T10:53:46","modified_gmt":"2020-12-31T02:53:46","slug":"gbase-8a%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%87%bd%e6%95%b0bit_length%e7%9a%84%e7%94%a8%e6%b3%95%e5%92%8c%e4%be%8b%e5%ad%90","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/2682","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a\u5b57\u7b26\u4e32\u51fd\u6570bit_length\u7684\u7528\u6cd5\u548c\u4f8b\u5b50"},"content":{"rendered":"<p>\u672c\u6587\u4ecb\u7ecdGBase 8a\u6570\u636e\u5e93\u96c6\u7fa4\u7684bit_length\u51fd\u6570\u7684\u8bed\u6cd5\u3001\u4f7f\u7528\u8bf4\u660e\u548c\u4f8b\u5b50\u3002<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Directory Navigation<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2b165fec60a\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2b165fec60a\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.gbase8.cn\/en\/2682\/#%E8%AF%AD%E6%B3%95\" >\u8bed\u6cd5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.gbase8.cn\/en\/2682\/#%E8%AF%B4%E6%98%8E\" >\u8bf4\u660e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.gbase8.cn\/en\/2682\/#%E6%A0%B7%E4%BE%8B\" >\u6837\u4f8b<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.gbase8.cn\/en\/2682\/#%E5%AD%97%E7%AC%A6%E4%B8%B2ASCII\" >\u5b57\u7b26\u4e32ASCII<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.gbase8.cn\/en\/2682\/#%E6%B1%89%E5%AD%97\" >\u6c49\u5b57<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.gbase8.cn\/en\/2682\/#UTF8%E7%BC%96%E7%A0%81\" >UTF8\u7f16\u7801<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.gbase8.cn\/en\/2682\/#GBK%E7%BC%96%E7%A0%81\" >GBK\u7f16\u7801<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.gbase8.cn\/en\/2682\/#%E6%95%B0%E5%AD%97\" >\u6570\u5b57<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.gbase8.cn\/en\/2682\/#%E7%9B%B4%E6%8E%A5%E6%95%B0%E5%AD%97\" >\u76f4\u63a5\u6570\u5b57<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.gbase8.cn\/en\/2682\/#%E7%94%A8hex%E8%BD%AC%E6%8D%A2%E6%88%90%E6%95%B0%E5%AD%97\" >\u7528hex\u8f6c\u6362\u6210\u6570\u5b57<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.gbase8.cn\/en\/2682\/#16%E8%BF%9B%E5%88%B6%E6%95%B0\" >16\u8fdb\u5236\u6570<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.gbase8.cn\/en\/2682\/#NULL%E5%80%BC\" >NULL\u503c<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.gbase8.cn\/en\/2682\/#%E5%8F%82%E8%80%83\" >\u53c2\u8003<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%AF%AD%E6%B3%95\"><\/span>\u8bed\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>BIT_LENGTH(str)\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%AF%B4%E6%98%8E\"><\/span>\u8bf4\u660e<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u8fd4\u56de\u5b57\u7b26\u4e32 str \u7684\u6bd4\u7279\u957f\u5ea6\uff0c\u4ee5\u6bd4\u7279\u8fdb\u884c\u8ba1\u7b97\u3002<\/p>\n\n\n\n<p>\u6ce8\u610f\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u4f60\u8f93\u5165\u7684\u662f\u6570\u5b57\uff0c\u4f1a\u5148\u8f6c\u6362\u6210\u5bf9\u5e94\u7684\u5b57\u7b26\u4e32\uff0c\u6bd4\u598210\uff0c\u4ed6\u4f1a\u53d8\u6210'10'\u6765\u5904\u7406\uff0c\u800c\u4e0d\u662f\u6570\u5b5710\u3002<\/p>\n\n\n\n<p>\u7a7a\u5b57\u7b26\u4e32\u8fd4\u56de\u957f\u5ea60<\/p>\n\n\n\n<p>null\u503c\u8fd4\u56de null.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%A0%B7%E4%BE%8B\"><\/span>\u6837\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%AD%97%E7%AC%A6%E4%B8%B2ASCII\"><\/span>\u5b57\u7b26\u4e32ASCII<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u6bcf\u4e2aASCII\u5b57\u7b26\u5360\u75288\u4f4d\u3002\u7a7a\u5b57\u7b26\u4e32\u8fd4\u56de0.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; select bit_length('');\n+----------------+\n| bit_length('') |\n+----------------+\n|              0 |\n+----------------+\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase&gt; select bit_length('A');\n+-----------------+\n| bit_length('A') |\n+-----------------+\n|               8 |\n+-----------------+\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase&gt; select bit_length('AB');\n+------------------+\n| bit_length('AB') |\n+------------------+\n|               16 |\n+------------------+\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase&gt; select bit_length('ABC');\n+-------------------+\n| bit_length('ABC') |\n+-------------------+\n|                24 |\n+-------------------+\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase&gt; select bit_length('ABCD');\n+--------------------+\n| bit_length('ABCD') |\n+--------------------+\n|                 32 |\n+--------------------+\n1 row in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%B1%89%E5%AD%97\"><\/span>\u6c49\u5b57<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"UTF8%E7%BC%96%E7%A0%81\"><\/span>UTF8\u7f16\u7801<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>\u6bcf\u4e2a\u5360\u75283\u4e2a\u5b57\u828224\u4f4d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; select bit_length('\u4e2d');\n+-------------------+\n| bit_length('\u4e2d')  |\n+-------------------+\n|                24 |\n+-------------------+\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase&gt; select bit_length('\u4e2d\u56fd');\n+----------------------+\n| bit_length('\u4e2d\u56fd')   |\n+----------------------+\n|                   48 |\n+----------------------+\n1 row in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"GBK%E7%BC%96%E7%A0%81\"><\/span>GBK\u7f16\u7801<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>\u6bcf\u4e2a\u5b57\u7b26\u5360\u75282\u4e2a\u5b57\u8282\uff0c16\u4f4d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; create table t_gbk(name varchar(100))default charset=gbk;\nQuery OK, 0 rows affected (Elapsed: 00:00:00.42)\n\ngbase&gt; insert into t_gbk values('\u4e2d'),('\u4e2d\u56fd');\nQuery OK, 2 rows affected (Elapsed: 00:00:00.27)\nRecords: 2  Duplicates: 0  Warnings: 0\n\ngbase&gt; select name,bit_length(name) from t_gbk\n    -&gt; ;\n+--------+------------------+\n| name   | bit_length(name) |\n+--------+------------------+\n| \u4e2d     |               16 |\n| \u4e2d\u56fd   |               32 |\n+--------+------------------+\n2 rows in set (Elapsed: 00:00:00.01)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%95%B0%E5%AD%97\"><\/span>\u6570\u5b57<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%9B%B4%E6%8E%A5%E6%95%B0%E5%AD%97\"><\/span>\u76f4\u63a5\u6570\u5b57<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>\u53c2\u6570\u76f4\u63a5\u5199\u6570\u5b57\uff0c\u4f1a\u88ab\u5148\u8f6c\u5316\u6210\u5bf9\u5e94\u7684\u5b57\u7b26\u4e32\u3002\u4e0e\u9884\u671f\u4e0d\u7b26\u3002\u5982\u4e0b\u6570\u5b5710\u5bf9\u5e940xA\u53ea\u5360\u75288\u4f4d\uff0c\u4f4610\u53d8\u6210\u4e86'10' \u5219\u5360\u7528\u4e8616\u4f4d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; select bit_length(1);\n+---------------+\n| bit_length(1) |\n+---------------+\n|             8 |\n+---------------+\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase&gt; select bit_length(10);\n+----------------+\n| bit_length(10) |\n+----------------+\n|             16 |\n+----------------+\n1 row in set (Elapsed: 00:00:00.01)\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%94%A8hex%E8%BD%AC%E6%8D%A2%E6%88%90%E6%95%B0%E5%AD%97\"><\/span>\u7528hex\u8f6c\u6362\u6210\u6570\u5b57<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>\u7528hex\u907f\u514d\u4e86\u5b57\u7b26\u4e32\u7684\u8f6c\u6362\uff0c\u800c\u662f\u6539\u6210\u4e8616\u8fdb\u5236\u6570\uff0c\u5176\u957f\u5ea6\u7b26\u5408\u9884\u671f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; select hex(10),bit_length(hex(10));\n+---------+---------------------+\n| hex(10) | bit_length(hex(10)) |\n+---------+---------------------+\n| A       |                   8 |\n+---------+---------------------+\n1 row in set (Elapsed: 00:00:00.00)\ngbase&gt; select hex(100),bit_length(hex(100));\n+----------+----------------------+\n| hex(100) | bit_length(hex(100)) |\n+----------+----------------------+\n| 64       |                   16 |\n+----------+----------------------+\n1 row in set (Elapsed: 00:00:00.00)\ngbase&gt; select hex(257),bit_length(hex(257));\n+----------+----------------------+\n| hex(257) | bit_length(hex(257)) |\n+----------+----------------------+\n| 101      |                   24 |\n+----------+----------------------+\n1 row in set (Elapsed: 00:00:00.00)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"16%E8%BF%9B%E5%88%B6%E6%95%B0\"><\/span>16\u8fdb\u5236\u6570<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>\u76f4\u63a5\u752816\u8fdb\u5236\u8868\u8fbe\u5f62\u5f0f\uff0c\u53ef\u4ee5\u83b7\u5f97\u6b63\u786e\u7684\u7ed3\u679c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; select bit_length(x'AA');\n+-------------------+\n| bit_length(x'AA') |\n+-------------------+\n|                 8 |\n+-------------------+\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase&gt; select bit_length(x'AABB');\n+---------------------+\n| bit_length(x'AABB') |\n+---------------------+\n|                  16 |\n+---------------------+\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"NULL%E5%80%BC\"><\/span>NULL\u503c<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; select bit_length(null);\n+------------------+\n| bit_length(null) |\n+------------------+\n|             NULL |\n+------------------+\n1 row in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8F%82%E8%80%83\"><\/span>\u53c2\u8003<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-\u8001\u7d2b\u7af9\u7684\u5bb6 wp-block-embed-\u8001\u7d2b\u7af9\u7684\u5bb6\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"3tv0j95lON\"><a href=\"https:\/\/www.gbase8.cn\/en\/2672\/\">GBase 8a\u5b57\u7b26\u4e32\u51fd\u6570\u6c47\u603b\u5217\u8868<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"\u300aGBase 8a\u5b57\u7b26\u4e32\u51fd\u6570\u6c47\u603b\u5217\u8868\u300b\u2014\u8001\u7d2b\u7af9\u7684\u5bb6\" src=\"https:\/\/www.gbase8.cn\/2672\/embed#?secret=3tv0j95lON\" data-secret=\"3tv0j95lON\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u4ecb\u7ecdGBase 8a\u6570\u636e\u5e93\u96c6\u7fa4\u7684bit_length\u51fd\u6570\u7684\u8bed\u6cd5\u3001\u4f7f\u7528\u8bf4\u660e\u548c\u4f8b\u5b50\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[36],"class_list":["post-2682","post","type-post","status-publish","format-standard","hentry","category-gbase8a","tag-36"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/2682","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=2682"}],"version-history":[{"count":3,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/2682\/revisions"}],"predecessor-version":[{"id":2689,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/2682\/revisions\/2689"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=2682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=2682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=2682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}