Translate

2013/03/15

Delphi xe2簡繁轉換函數

delphi xe2簡繁轉換函數  

function Cn2Big(CnStr: string): string;    //簡體中文轉繁體中文
var
 Len: Integer;
begin
 Len := Length(CnStr);
 SetLength(Result, Len);
 LCMapString(GetUserDefaultLCID, LCMAP_TRADITIONAL_CHINESE, PChar(CnStr), Len, PChar(Result), Len);
end;
//----------------------------------------
function Big2Cn(BigStr: string): string;   //繁體中文轉簡體中文
var
 Len: Integer;
begin
 Len := Length(BigStr);
 SetLength(Result, Len);
 LCMapString(GetUserDefaultLCID, LCMAP_SIMPLIFIED_CHINESE, PChar(BigStr), Len, PChar(Result), Len);
end;

關鍵是LCMapString的第二個參數,不同的值可以做許多不同的功能,如按字節倒轉、簡繁轉換、大小寫轉換等。函數原型如下:
int LCMapString( LCID, DWORD, LPCTSTR, int, LPTSTR, int);

DataSnap REST API Authorization with PHP

About Authentication with DataSet REST JavaScript client. In connection.js: function setCredentials(user, password) { connectionInf...