{"id":3405,"date":"2016-01-07T14:42:19","date_gmt":"2016-01-07T06:42:19","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=3405"},"modified":"2016-01-07T14:42:19","modified_gmt":"2016-01-07T06:42:19","slug":"delphi-%e8%bf%9b%e5%88%b6%e8%bd%ac%e6%8d%a2%e4%b9%8b10%e8%bf%9b%e5%88%b6%e4%b8%8e34%e8%bf%9b%e5%88%b6%e4%ba%92%e8%bd%ac","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=3405","title":{"rendered":"[Delphi] \u8fdb\u5236\u8f6c\u6362\u4e4b10\u8fdb\u5236\u4e0e34\u8fdb\u5236\u4e92\u8f6c"},"content":{"rendered":"<p>\u55ef\uff0c\u4eca\u5929\u9633\u5149\u660e\u5a9a\uff0c\u7a7a\u6c14\u6e05\u65b0\uff0c\u5fc3\u60c5\u6109\u5feb\uff0c\u8fd8\u4e0d\u5fd9\u3002\u6b63\u597d\u6709\u4eba\u8bf4\u5230\u8fdb\u5236\u8f6c\u6362\uff0c\u5c31\u8bd5\u7740\u505a\u4e86\u4e00\u4e0b\u3002<\/p>\n<p>\u6b64\u5904\u7701\u7565\u4e00\u5343\u5b57\u7684\u5e9f\u8bdd\u3002\u3002\u3002\u3002<\/p>\n<p>\u5148\u4e0a\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3406\" src=\"https:\/\/blog.qdac.cc\/wp-content\/uploads\/2016\/01\/QQ\u622a\u56fe20160107143906.jpg\" alt=\"QQ\u622a\u56fe20160107143906\" width=\"598\" height=\"281\" srcset=\"https:\/\/blog.qdac.cc\/wp-content\/uploads\/2016\/01\/QQ\u622a\u56fe20160107143906.jpg 598w, https:\/\/blog.qdac.cc\/wp-content\/uploads\/2016\/01\/QQ\u622a\u56fe20160107143906-300x141.jpg 300w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><\/p>\n<p>\u4e0b\u9762\u76f4\u63a5\u4e0a\u4ee3\u7801\uff0c\u5e0c\u671b\u5927\u5bb6\u80fd\u770b\u660e\u767d\u3002<\/p>\n<pre class=\"lang:delphi decode:true \">unit Unit1;\r\n\r\ninterface\r\n\r\nuses\r\n  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,\r\n  Dialogs, StdCtrls;\r\n\r\ntype\r\n  TForm1 = class(TForm)\r\n    Edit1: TEdit;\r\n    Edit2: TEdit;\r\n    Button1: TButton;\r\n    Button2: TButton;\r\n    procedure Button2Click(Sender: TObject);\r\n    procedure Button1Click(Sender: TObject);\r\n  private\r\n    { Private declarations }\r\n  public\r\n    { Public declarations }\r\n  end;\r\n\r\nvar\r\n  Form1: TForm1;\r\n\r\nimplementation\r\n\r\n{$R *.dfm}\r\n\r\nconst\r\n  Convert: array[0..255] of Integer =\r\n    (\r\n     -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n     -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n     -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n      0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,\r\n     -1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,\r\n     25,26,27,28,29,30,31,32,33,-1,-1,-1,-1,-1,-1,-1,\r\n     -1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,\r\n     25,26,27,28,29,30,31,32,33,-1,-1,-1,-1,-1,-1,-1,\r\n     -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n     -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n     -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n     -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n     -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n     -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n     -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\r\n     -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1\r\n     );\r\n  Convert2: array[0..33] of AnsiChar =\r\n    (\r\n     '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f',\r\n     'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',\r\n     'w','x');\r\n\r\n\r\nfunction IntToHEX34(const V: Int64; const Digits: Integer = -1): string;\r\nconst\r\n  CSTR = '0000000000000000';\r\nvar\r\n  P, P1: PAnsiChar;\r\n  I: Int64;\r\n  NewLen: Integer;\r\nbegin\r\n  GetMem(P, 16);\r\n  Move(CSTR, P^, 16);\r\n  P1 := P + 16 - 1;\r\n  I := V;\r\n  while True do begin\r\n    P1^ := Convert2[I mod 34];\r\n    I := I div 34;\r\n    if I = 0 then\r\n      Break\r\n    else\r\n      Dec(P1);\r\n  end;\r\n  NewLen := 16 - (P1 - P);\r\n  if NewLen &gt; Digits then\r\n    SetString(Result, P1, NewLen)\r\n  else begin\r\n    P1 := P + 16 - Digits;\r\n    SetString(Result, P1, Digits);\r\n  end;\r\nend;\r\n\r\nfunction HEX34ToInt(const S: string; const Default: Int64): Int64;\r\nvar\r\n  I: Integer;\r\n  v: Int64;\r\nbegin\r\n  Result := 0;\r\n  for I := 1 to length(s) do\r\n  begin\r\n    V := Convert[ord(s[i])];\r\n    if V &lt; 0 then begin\r\n      Result := Default;\r\n      Exit;\r\n    end;\r\n    result := (result * 34) + V;\r\n  end;\r\nend;\r\n\r\nprocedure TForm1.Button1Click(Sender: TObject);\r\nbegin\r\n  Edit2.Text := IntToHEX34(StrToInt64Def(Edit1.Text, 0));\r\nend;\r\n\r\nprocedure TForm1.Button2Click(Sender: TObject);\r\nbegin\r\n  Edit1.Text := IntToStr(HEX34ToInt(Edit2.Text, 0));\r\nend;\r\n\r\nend.\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>34\u8fdb\u5236\uff0c\u4e0d\u597d\u4f18\u5316\u3002\u8981\u662f32\u8fdb\u5236\uff0c\u9664\u6cd5\u7684\u5730\u65b9\u548c\u4e58\u6cd5\u5730\u65b9\uff0c\u5e94\u8be5\u53ef\u4ee5\u6362\u6210\u79fb\u4f4d\u64cd\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u55ef\uff0c\u4eca\u5929\u9633\u5149\u660e\u5a9a\uff0c\u7a7a\u6c14\u6e05\u65b0\uff0c\u5fc3\u60c5\u6109\u5feb\uff0c\u8fd8 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[8],"tags":[],"class_list":["post-3405","post","type-post","status-publish","format-standard","hentry","category-delphi"],"views":4141,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/3405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3405"}],"version-history":[{"count":1,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/3405\/revisions"}],"predecessor-version":[{"id":3407,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/3405\/revisions\/3407"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}