Get the pinyin of Chinese characters

xiaoxiao2021-03-05  24

Function TFORM1.GETPY (SHZ: STRING): String;

VAR

i: integer;

Py: string;

String;

Function getPyindexchar (hzchar: string): char;

Begin

Case Word (Hzchar [1]) SHL 8 Word (Hzchar [2]) of

$ B0a1 .. $ b0c4: result: = 'a';

$ B0c5 .. $ b2c0: result: = 'b';

$ B2c1 .. $ b4ed: result: = 'c';

$ B4ee .. $ b6e9: result: = 'd';

$ B6ea .. $ b7a1: result: = 'e';

$ B7a2 .. $ b8c0: result: = 'f';

$ B8c1 .. $ b9fd: result: = 'g';

$ B9fe .. $ bbf6: result: = 'h';

$ Bbf7 .. $ bfa5: result: = 'J';

$ Bfa6 .. $ c0Ab: result: = 'k';

$ C0ac .. $ c2e7: result: = 'L';

$ C2e8 .. $ c4c2: result: = 'm';

$ C4C3 .. $ C5B5: Result: = 'n';

$ C5B6 .. $ c5bd: result: = 'o';

$ C5be .. $ c6d9: result: = 'p';

$ C6da .. $ c8ba: result: = 'q';

$ C8bb .. $ c8f5: result: = 'r';

$ C8f6 .. $ cbf9: result: = 's';

$ Cbfa .. $ cdd9: result: = 't';

$ Cdda .. $ CEF3: RESULT: = 'W';

$ CEF4 .. $ D188: Result: = 'x';

$ D1b9 .. $ d4d0: result: = 'y';

$ D4D1 .. $ D7F9: Result: = 'Z';

Else

Result: = CHAR (32);

END;

END;

Begin

s: = '';

I: = 1;

While I <= Length (SHZ) DO

Begin

PY: = COPY (SHZ, I, 1);

IF py> = chr (128) THEN

Begin

INC (I);

PY: = Py Copy (SHZ, I, 1);

S: = S getPyindexchar (py);

end

Else

s: = s py;

INC (I);

END;

Result: = S;

END;

转载请注明原文地址:https://www.9cbs.com/read-35808.html

New Post(0)