Move UTF8 to UTF16LE conversion into function in utils.
Misc cleanup and change utf conversion signature.