Added UTF-8 compatibility to multi-line algorithm.