WrapText for WideString in Delphi

拟墨画扇 提交于 2019-12-22 05:01:03

问题


Delphi has a WrapText function:

function WrapText(const Line, BreakStr: string; const BreakChars: TSysCharSet; MaxCol: Integer): string;
function WrapText(const Line: string; MaxCol: Integer): string;

Now i need a version that handles WideStrings:

function WrapTextW(const Line: WideString; MaxCol: Integer): WideString;

Is any such function written somewhere already?

WARNING: Not every wide string character is 2-bytes

Which is why i'm afraid to write it

Update: Example of a character that takes more than 2-bytes to represent:

Capital Latin W with ring and cedilla

  • Bytes: 57 00 66 03 27 03
  • Rendered in Chrome 17:

  • Rendered in Internet Explorer 9:

  • Rendered in Notepad using Segoe UI:

  • Rendered in Notepad using Consolas:

  • Rendered in your browser in sans-serif font: W̧̊
  • Rendered in your browser in monospaced font: W̧̊

回答1:


As mentioned by kobik, TNT UnicodeControls has a unit TntSysUtils which includes following function :

function WideWrapText(const Line, BreakStr: WideString; const BreakChars: TSysCharSet;
  MaxCol: Integer): WideString; overload;
function WideWrapText(const Line: WideString; MaxCol: Integer): WideString; overload;

Alternate download site is here.



来源:https://stackoverflow.com/questions/9703491/wraptext-for-widestring-in-delphi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!