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;

相关阅读 >>

Delphi 2010 unicode

Delphi firemonkey 图片显示拉伸不变形

Delphi简单判断程序30秒没有键盘和鼠标动作示例

Delphi 如何通过代码控制打开键盘数字锁定numlock

Delphi xe5-android开发 目录结构

Delphi 创建进程时指定其父进程

Delphi windows 获取指定进程句柄数

Delphi 删除动态数组的指定元素

Delphi 无法打不开读取文件名有逗号的文件

Delphi yesterday、today、tomorrow - 昨天、今天、明天

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...