低版本delphi 处理unicode
1
function CopyW(ws: WideString; Start, Len: integer): WideString;
2
var
3
wslen: integer;
4
sp: PWideChar;
5
begin
6
if Start < 1 then start := 1;
7
8
if Len < 1 then begin result := ''; exit; end;
9
10
wslen := lstrlenw(PWideChar(ws));
11
if wslen < (Start + Len - 1) then
12
len := wslen + 1 - Start;
13
14
result := stringofchar(' ', Len);
15
sp := PWideChar(ws);
16
Inc(sp, Start - 1);
17
CopyMemory(PWideChar(result), SP, len * 2);
18
end;
低版本的delphi 处理Unicode 很麻烦,不可以用任何与string相关的函数,就是说,所有的控件,字符串函数得自己重写
function CopyW(ws: WideString; Start, Len: integer): WideString;2
var3
wslen: integer;4
sp: PWideChar;5
begin6
if Start < 1 then start := 1;7

8
if Len < 1 then begin result := ''; exit; end;9

10
wslen := lstrlenw(PWideChar(ws));11
if wslen < (Start + Len - 1) then12
len := wslen + 1 - Start;13

14
result := stringofchar(' ', Len);15
sp := PWideChar(ws);16
Inc(sp, Start - 1);17
CopyMemory(PWideChar(result), SP, len * 2);18
end;
浙公网安备 33010602011771号