Why
$output = '<hello';
echo mb_convert_encoding( $output, 'UTF-16', 'UTF-8' );
displays
<�hello
I was expecting
<hello
Any ideas?
Edit: Seems related to the browser because it works in command line. But I still don't understand...
Why
$output = '<hello';
echo mb_convert_encoding( $output, 'UTF-16', 'UTF-8' );
displays
<�hello
I was expecting
<hello
Any ideas?
Edit: Seems related to the browser because it works in command line. But I still don't understand...
$ echo '<hello' | od -x
0000000 683c 6c65 6f6c 000a
0000007
$ php -v
PHP 7.3.11 (cli) (built: Jun 5 2020 23:50:40) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
$ cat hoge.php
<?php
$output = '<hello';
echo mb_convert_encoding( $output, 'UTF-16', 'UTF-8' );
$ php hoge.php | od -x
0000000 3c00 6800 6500 6c00 6c00 6f00
0000014
I tried it. Is that right?