Imaulle Posted April 12, 2012 Share Posted April 12, 2012 Can someone help me figure out what this does exactly and is it possible to do the same thing without using mb_convert_encoding? I need to be able to do this function without that lib public static function getCodePoint($char) { $cp = unpack('N', mb_convert_encoding($char, 'UCS-4BE', 'UTF-8')); return $cp[1]; } This is from the Cufon generator code that converts ttf to js... Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/260783-help-with-a-cufon-function/ Share on other sites More sharing options...
Imaulle Posted April 12, 2012 Author Share Posted April 12, 2012 upon further investigating I've found out that it's a unicode-friendly version of ord(). - mb_convert_encoding($char, 'UCS-4BE', 'UTF-8') converts a UTF-8 character to UCS-4BE. - UCS-4BE is 32-bit unicode big endian. - unpack unpacks binary data into an associative array. - N specifies unsigned long 32-bit big endian as the format. - $cp[1] returns the second index of the associative array. However I'm still unable to figure out how to do this without using mb_convert_encoding.... Anyone got any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/260783-help-with-a-cufon-function/#findComment-1336784 Share on other sites More sharing options...
xyph Posted April 12, 2012 Share Posted April 12, 2012 Have you tried the iconv set of functions? iconv( 'UTF-8','UCS-4BE',$str ); Quote Link to comment https://forums.phpfreaks.com/topic/260783-help-with-a-cufon-function/#findComment-1336793 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.