zoukankan      html  css  js  c++  java
  • 有意思的中文转拼音用来区分26个小类用于缩小列表大小减少循环

    0...25 = 26 TListArray
    function GetFirstChar(const AHzStr: string): string;
    const
    ChinaCode: array[0..25, 0..1] of Integer = ((1601, 1636),
    (1637, 1832),
    (1833, 2077),
    (2078, 2273),
    (2274, 2301),
    (2302, 2432),
    (2433, 2593),
    (2594, 2786),
    (9999, 0000),
    (2787, 3105),
    (3106, 3211),
    (3212, 3471),
    (3472, 3634),
    (3635, 3722),
    (3723, 3729),
    (3730, 3857),
    (3858, 4026),
    (4027, 4085),
    (4086, 4389),
    (4390, 4557),
    (9999, 0000),
    (9999, 0000),
    (4558, 4683),
    (4684, 4924),
    (4925, 5248),
    (5249, 5589));
    var
    i, j, HzOrd: Integer;
    begin
    i := 1;
    while i <= Length(AHzStr) do
    begin
    if (AHzStr[i] >= #160) and (AHzStr[i + 1] >= #160) then
    begin
    HzOrd := (Ord(AHzStr[i]) - 160) * 100 + Ord(AHzStr[i + 1]) - 160;
    for j := 0 to 25 do
    begin
    if (HzOrd >= ChinaCode[j][0]) and (HzOrd <= ChinaCode[j][1]) then
    begin
    Result := Result + Char(Byte('A') + j);
    Break;
    end;
    end;
    Inc(i);
    end else Result := Result + AHzStr[i];
    Inc(i);
    end;
    Result := UpperCase(Result);
    end;

    function GetWWIndex(const S: string): Integer;
    var
    Str2: string;
    begin
    Str2 := GetFirstChar(S);
    Result := High(TListArray);
    if Str2 <> '' then
    begin
    Result := Ord(Str2[1]);
    if Result < 65 then
    Result := Result - 47 + 90;
    end;
    if Result > High(TListArray) - 1
    then Result := High(TListArray);
    end;

  • 相关阅读:
    mysql 修改表
    mac下安装MySQL 5.7
    win&linux下path中%%与$ 以及;与:区别,
    PATH
    转 path设置方式
    MyEclipse乱码问题
    03 最大的数据库 information_schema介绍以及sql注入第一题题解
    02.mysql数据库 基本命令
    01.Windows进入MySQL数据库
    Web web4
  • 原文地址:https://www.cnblogs.com/marklove/p/14201697.html
Copyright © 2011-2022 走看看