Multi-byte safe wordwrap() function for UTF-8

tazz

New Member
PHP's \[code\]wordwrap()\[/code\] function doesn't work correctly for multi-byte strings like UTF-8.There are a few examples of mb safe functions in the comments, but with some different test data they all seem to have some problems.The function should take the exact same parameters as \[code\]wordwrap()\[/code\].Specifically be sure it works to:
  • cut mid-word if \[code\]$cut = true\[/code\], don't cut mid-word otherwise
  • not insert extra spaces in words if \[code\]$break = ' '\[/code\]
  • also work for \[code\]$break = "\n"\[/code\]
  • work for ASCII, and all valid UTF-8
 
Back
Top