游子日月长

笑渐不闻声渐悄,多情却被无情恼!

导航

从给定字符串中截取n个字节的字符(解决汉字截取乱码问题)

function GetNBytesChar(s: Ansistring; n: Integer): string;
var
  aStr: AnsiString;
  bStr: WideString;
begin
  aStr := Copy(s, 1, n);
  bStr := aStr;
  if aStr = bStr then
    Result := astr
  else
    Result := Copy(s, 1, n-1);
end;

posted on 2017-01-20 21:56  游子日月长  阅读(188)  评论(0编辑  收藏  举报