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
13 * @param string $string characters to calculate unicode of
14 * @param string $encoding encoding of $string, if null mb_internal_encoding() is used
15 * @return array sequence of unicodes
18 function smarty_mb_to_unicode($string, $encoding=null) {
20 $expanded = mb_convert_encoding($string, "UTF-32BE", $encoding);
22 $expanded = mb_convert_encoding($string, "UTF-32BE");
24 return unpack("N*", $expanded);
28 * convert unicodes to the character of given encoding
30 * @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration
31 * @param integer|array $unicode single unicode or list of unicodes to convert
32 * @param string $encoding encoding of returned string, if null mb_internal_encoding() is used
33 * @return string unicode as character sequence in given $encoding
36 function smarty_mb_from_unicode($unicode, $encoding=null) {
39 $encoding = mb_internal_encoding();
41 foreach((array) $unicode as $utf32be) {
42 $character = pack("N*", $utf32be);
43 $t .= mb_convert_encoding($character, $encoding, "UTF-32BE");