Fix up "TextDialog: Improve the average and worst-case performance of word wrapping."

The performance is not improved as much, but now the behavior is correct even
in the face of possibly cutting up a character in the middle of its UTF-8
encoding.