Convert a utf-8 string to a utf-16 string in PHP

by in 0

- You could also use iconv.
It's native in PHP, but require that all your text is one charset. Else it could discard characters.
iconv("UTF-8""UTF-16"$text)

- In other way, mbstring supports UTF-16, so you can use mb_convert_encoding.

source

Leave a Reply