delphi 中文字符串截取  
官方Delphi 学习QQ群: 682628230(三千人)
频道

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;

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.094995975494385 seconds