2012-03-14 90 views
7

德爾福有一個WrapText功能:WrapText爲WideString的德爾福

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

現在我需要一個處理WideStrings版本:

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

寫入已經某處任何這樣的功能呢?

警告:並不是每一個寬字符串的字符爲2個字節

這就是爲什麼我怕寫

更新:這需要超過2字符的示例-bytes表示:

資本拉丁W的環和變音符號

  • 字節:使用索拉enter image description here
  • 渲染在記事本中:57 00 66 03 27 03
  • 渲染在鉻17:enter image description here
  • 在Internet Explorer 9渲染:enter image description here使用在記事本
  • 渲染瀨越UI :enter image description here
  • 在瀏覽器中以無襯線字體呈現:W̧̊
  • 在您的瀏覽器中呈現在monospaced字體:W̧̊
+2

這將導致可能從Delphi 2009複製源代碼作爲答案。 +1反正 – TLama 2012-03-14 14:08:44

+5

@TLama:這就是爲什麼我把它標記爲德爾福的最後一個版本,沒有更好的寬帶支持(讓大衛離開我的後背!) – 2012-03-14 14:14:13

+4

Tnt組件套裝在'TntSysUtils.pas'中有'WideWrapText' – kobik 2012-03-14 14:21:10

回答

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; 

備用下載站點是here