MyBB Community Forums

Full Version: [F] my_substr(): Problem with umlauts [C-Imad Jomaa]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
MyBB 1.4.4 includes a fix for a problem with unicode characters and the my_wordwrap() function (Bug #40223).

Something similar seems to appear in the my_substr() function: If an unicode character (e.g. an umlaut) is the last character it gets messed up.
Can you copy and paste what it should be here so I can reproduce on my own localhost?

I think these are two separate issues.
It should be "Pfannkuchen mit roter Soße" and "Überbackene Chiabattabrötchen".
Works fine here
I was facing the same thing when the mbstring module is not enabled
I'll ask the user who reported this issue about that.
You're right, the mbstring module is not enabled on his host.
I think we can pretty much state in the requirements that mbstring is needed for internationalization forums if they want 100% support for multi-byte characters
I'll mark this as not fixable unless anyone else has a brilliant idea to be able to use the "u" modifier with preg and not screw it up for forums that don't support that. The one way to tell that I know of is to:

count the number of ? marks in the original string. run the preg function with "u" and count the number of ? marks afterward. If they're not the same then we know it doesn't support it and it runs the preg without the "u" modifier. The problem with that is that it's really crappy and your doing twice the processing for just one preg sometimes.

I guess the other solution is to run a test on the upgrade / installation, but I don't know if that'll be guaranteed to be correct. However if we could get that to work we can just do an

function my_preg_replace(...) { if($mybb->settings['preg_unicode'] == 1) { preg...with...unicode } else { preg...without...unicode } return string }

So I'm hoping for someone with a good idea.

Making it a setting seems the best idea to me, maybe combined with a fallback to the non-unicode variant if the unicode one throws an error or returns nothing, so it doesn't break completely if preg_unicode is set to 1 and the server removes support for it.
Pages: 1 2