tchwork / utf8

Portable and performant UTF-8, Unicode and Grapheme Clusters for PHP
Apache License 2.0
627 stars 50 forks source link

Error when using Utf8::strlen() function. #57

Closed basilmusa closed 8 years ago

basilmusa commented 8 years ago

I'm using php 5.5.19. I don't have mb_string, iconv or intl extensions enabled.

I get the following error when using Utf8::strlen(..):

Fatal error:  Call to undefined function Patchwork\grapheme_strlen() in ....\vendor\patchwork\utf8\src\Patchwork\Utf8.php on line 234

According to the documentation, there is a fallback implementation, but when trying Utf8::strlen() no fallback implementation is active.

Am I doing something wrong, or does Utf8::strlen() require intl extension to be enabled? By what other means can I get the length of a utf8 string?

Thanks in advance.

basilmusa commented 8 years ago

Okay, my mistake. I should have called the following at the top of my test file:

\Patchwork\Utf8\Bootup::initAll(); // Enables the portablity layer and configures PHP for UTF-8 \Patchwork\Utf8\Bootup::filterRequestUri(); // Redirects to an UTF-8 encoded URL if it's not already the case \Patchwork\Utf8\Bootup::filterRequestInputs(); // Normalizes HTTP inputs to UTF-8 NFC