Delphi繁简转换源码函数

Function GBCht2Chs(GBStr: String): AnsiString;
{进行GBK繁体转简体}
Var
Len: integer;
pGBCHTChar: PChar;
pGBCHSChar: PChar;
Begin
pGBCHTChar := PChar(GBStr);
Len := MultiByteToWideChar(936, 0, pGBCHTChar, -1, Nil, 0);
GetMem(pGBCHSChar, Len * 2 + 1);
ZeroMemory(pGBCHSChar, Len * 2 + 1);
LCMapString($804, LCMAP_SIMPLIFIED_CHINESE, pGBCHTChar, -1, pGBCHSChar, Len * 2);
result := String(pGBCHSChar);
FreeMem(pGBCHSChar);
End;

Function GBChs2Cht(GBStr: String): AnsiString;
{进行GBK简体转繁体}
Var
Len: integer;
pGBCHTChar: PChar;
pGBCHSChar: PChar;
Begin
pGBCHSChar := PChar(GBStr);
Len := MultiByteToWideChar(936, 0, pGBCHSChar, -1, Nil, 0);
GetMem(pGBCHTChar, Len * 2 + 1);
ZeroMemory(pGBCHTChar, Len * 2 + 1);
LCMapString($804, LCMAP_TRADITIONAL_CHINESE, pGBCHSChar, -1, pGBCHTChar, Len * 2);
result := String(pGBCHTChar);
FreeMem(pGBCHTChar);
End;

Memo1.text:=GBChs2Cht(Memo1.text);   //简体转繁体

Memo1.text:=GBCht2Chs(Memo1.text); //繁体转简体