Andarian Posted December 19, 2007 Share Posted December 19, 2007 I've tried searching first.. but couldnt really tell how to find a name for my problem.. I'm sure others have been running into the same problem as well. The problem is when I try to use substr to cut some text from a large utf-8 string, I cant tell how much to cut because the encoding length is variable. (or is it?) Anyone has an idea? Quote Link to comment https://forums.phpfreaks.com/topic/82368-substr-and-unicode/ Share on other sites More sharing options...
lemmin Posted December 19, 2007 Share Posted December 19, 2007 Try this: http://www.php.net/manual/en/function.utf8-decode.php Quote Link to comment https://forums.phpfreaks.com/topic/82368-substr-and-unicode/#findComment-418738 Share on other sites More sharing options...
Andarian Posted December 19, 2007 Author Share Posted December 19, 2007 Not so sure if I can use that, cause the string is not in english and then when the function changes it to ISO-8859-1 I cant show it. Quote Link to comment https://forums.phpfreaks.com/topic/82368-substr-and-unicode/#findComment-418762 Share on other sites More sharing options...
corbin Posted December 19, 2007 Share Posted December 19, 2007 Try looking into http://www.php.net/mb_substr Quote Link to comment https://forums.phpfreaks.com/topic/82368-substr-and-unicode/#findComment-418766 Share on other sites More sharing options...
Andarian Posted December 19, 2007 Author Share Posted December 19, 2007 I've PHP 4.4.7 but I'm getting function not found for mb_substr . It does sound like the solution for my problem! Quote Link to comment https://forums.phpfreaks.com/topic/82368-substr-and-unicode/#findComment-418812 Share on other sites More sharing options...
corbin Posted December 19, 2007 Share Posted December 19, 2007 The mb extension must be enabled to use mb_ functions.... I don't remember the name of it, but it should be with the other commented out extensions in php.ini..... Or, if you don't have the access to enabled that, you might have to recreate it or find a different method. Quote Link to comment https://forums.phpfreaks.com/topic/82368-substr-and-unicode/#findComment-418839 Share on other sites More sharing options...
Andarian Posted December 20, 2007 Author Share Posted December 20, 2007 I've uncommented extension=php_mbstring.dll on php.ini, seems like it. I'm still getting the error though Quote Link to comment https://forums.phpfreaks.com/topic/82368-substr-and-unicode/#findComment-419345 Share on other sites More sharing options...
Andarian Posted December 20, 2007 Author Share Posted December 20, 2007 problem was extension dir. I have the function working but still getting very wierd results when trying to cut text from a unicode string Quote Link to comment https://forums.phpfreaks.com/topic/82368-substr-and-unicode/#findComment-419353 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.