Delphi中用于WideString的WrapText

Ian*_*oyd 7 delphi localization internationalization delphi-2007

Delphi有一个WrapText功能:

function WrapText(const Line, BreakStr: string; const BreakChars: TSysCharSet; MaxCol: Integer): string;
function WrapText(const Line: string; MaxCol: Integer): string;
Run Code Online (Sandbox Code Playgroud)

现在我需要一个处理WideStrings的版本:

function WrapTextW(const Line: WideString; MaxCol: Integer): WideString;
Run Code Online (Sandbox Code Playgroud)

是否有任何此类功能已写入某处?

警告:并非每个宽字符串字符都是2字节

这就是为什么我害怕写它

更新:占用超过2个字节的字符示例:

资本拉丁W与环和cedilla

  • 字节:57 00 66 03 27 03
  • 在Chrome 17中呈现: 在此输入图像描述
  • 在Internet Explorer 9中呈现: 在此输入图像描述
  • 使用Segoe UI在记事本中呈现: 在此输入图像描述
  • 使用Consolas在记事本中呈现: 在此输入图像描述
  • 在浏览器中以sans-serif字体呈现:W̧̊
  • 在浏览器中以monospaced字体呈现:W??

LU *_* RD 3

正如kobik所提到的,TNT UnicodeControls有一个单元TntSysUtils,其中包括以下功能:

function WideWrapText(const Line, BreakStr: WideString; const BreakChars: TSysCharSet;
  MaxCol: Integer): WideString; overload;
function WideWrapText(const Line: WideString; MaxCol: Integer): WideString; overload;
Run Code Online (Sandbox Code Playgroud)

备用下载站点在这里