Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/260783-help-with-a-cufon-function/
Share on other sites

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.