📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, XPMan;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
BitBtn1: TBitBtn;
CheckBox1: TCheckBox;
XPManifest1: TXPManifest;
procedure Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
procedure DoGetHzPinying;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses iStdComm, Clipbrd;
{$R *.dfm}
function gb2py(HanZi: String; Upper: Boolean=True): String;
var
I: Integer;
SFile: TMemoryStream;
pos, temp, ipos, len:integer;
lcHZ, S: String;
isHz: Boolean;
begin
Result := HanZi;
S := ExtractFilePath(Application.ExeName) + 'gb2py.idx';
if not FileExists(S) then Exit;
SFile := TMemoryStream.Create;
SFile.LoadFromFile(S);
I := 1;
Result := '';
while I<=Length(HanZi) do
begin
lcHZ := HanZi[I];
if HanZi[I] in LeadBytes then
begin
Inc(I);
lcHZ := lcHZ + HanZi[I];
pos := (Ord(lcHZ[1])- 176)*94 + Ord(lcHZ[2]) - 161;
SFile.Seek($1608 + pos*4, soFromBeginning);
SFile.Read(ipos, 4);
SFile.Read(temp, 4);
len := temp - ipos;
SFile.Seek(ipos + 1, soFromBeginning);
S := '';
SetLength(S, len-1);
SFile.Read(S[1], len);
if Trim(S)='' then
S := lcHZ
else
begin
Delete(S, Length(S), 1);
if (S<>'') and Upper then S[1] := Char(Ord(S[1]) - 32);
end;
Result := Result + ' ' + S;
isHz := True;
end else
begin
if isHz then
Result := Result + ' ';
Result := Result + lcHZ;
isHz := False;
end;
Inc(I);
end;
SFile.Free;
Result := Trim(Result);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.DoGetHzPinying;
begin
Edit2.Text := (gb2py(Edit1.Text));
if CheckBox1.Checked then
Clipboard.AsText := Edit2.Text;
end;
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_RETURN then
begin
DoGetHzPinying;
Key := 0;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -