10

How do I convert a utf-8 string to a utf-16 string in PHP?

Freddo411
  • 2,293
  • 3
  • 18
  • 17

2 Answers2

14

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

chroder
  • 4,393
  • 2
  • 27
  • 42
3

You could also use iconv.

It's native in PHP, but require that all your text is one charset. Else it could discard characters.

Chloe
  • 25,162
  • 40
  • 190
  • 357
Jesper Grann Laursen
  • 2,357
  • 1
  • 20
  • 21