- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi 中文字符串截取
procedure TForm1.Button1Click(Sender: TObject);
begin
memo3.Lines.Add( wShortFileName(edit1.Text,StrToInt(Edit2.Text)));
end;
function TForm1.wShortFileName(strFile: String; fnLen: Integer): String;
var
Str: String;
bWide: Boolean;
wStr: WideString;
i:integer;
D_Result:string;
begin
Result:=strFile;
if Length(strFile)<=fnLen then Exit;
Str:=strFile;
wStr:=strFile;
// bWide:=(Length(Str)<>Length(wStr));
{ while Length(Str)>(fnLen-2) do
begin
Delete(wStr,Length(wStr),1);
Str:=wStr;
end;}
for i := 1 to fnLen do
begin
D_Result:=D_Result+ copy(wStr,i,1);
end;
Result:=D_Result ;
end;