<?php $input = "sea \u{200B}\u{200B}lion"; echo preg_replace_callback('#\X#u', function($m) { $utf16 = mb_convert_encoding($m[0], 'UTF-16BE', 'UTF-8'); if (strlen($utf16) <= 2) { $esc = '\u' . bin2hex($utf16); } else { $esc = '\u' . bin2hex(substr($utf16, 0, 2)) . '\u' . bin2hex(substr($utf16, 2, 2)); } return $esc; }, $input);
You have javascript disabled. You will not be able to edit any code.