6 * @subpackage PluginsShared
10 * convert characters to their decimal unicode equivalents
12 * @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration
14 * @param string $string characters to calculate unicode of
15 * @param string $encoding encoding of $string, if null mb_internal_encoding() is used
17 * @return array sequence of unicodes
20 function smarty_mb_to_unicode($string, $encoding = null)
23 $expanded = mb_convert_encoding($string, "UTF-32BE", $encoding);
25 $expanded = mb_convert_encoding($string, "UTF-32BE");
28 return unpack("N*", $expanded);
32 * convert unicodes to the character of given encoding
34 * @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration
36 * @param integer|array $unicode single unicode or list of unicodes to convert
37 * @param string $encoding encoding of returned string, if null mb_internal_encoding() is used
39 * @return string unicode as character sequence in given $encoding
42 function smarty_mb_from_unicode($unicode, $encoding = null)
46 $encoding = mb_internal_encoding();
48 foreach ((array) $unicode as $utf32be) {
49 $character = pack("N*", $utf32be);
50 $t .= mb_convert_encoding($character, $encoding, "UTF-32BE");