MyBB Community Forums
[F] my_substr(): Problem with umlauts [C-Imad Jomaa] - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community Archive (https://community.mybb.com/forum-106.html)
+--- Forum: Archived Forums (https://community.mybb.com/forum-143.html)
+---- Forum: Archived Development and Support (https://community.mybb.com/forum-155.html)
+----- Forum: Archived Bug Reports (https://community.mybb.com/forum-74.html)
+------ Forum: MyBB 1.4.4 (https://community.mybb.com/forum-110.html)
+------ Thread: [F] my_substr(): Problem with umlauts [C-Imad Jomaa] (/thread-41759.html)

Pages: 1 2


[F] my_substr(): Problem with umlauts [C-Imad Jomaa] - Michael S. - 12-10-2008

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.


RE: my_substr(): Problem with umlauts - Ryan Gordon - 12-10-2008

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.


RE: my_substr(): Problem with umlauts - Michael S. - 12-10-2008

It should be "Pfannkuchen mit roter Soße" and "Überbackene Chiabattabrötchen".


RE: my_substr(): Problem with umlauts - Ryan Gordon - 12-10-2008

Works fine here


RE: my_substr(): Problem with umlauts - pepotiger - 12-11-2008

I was facing the same thing when the mbstring module is not enabled


RE: my_substr(): Problem with umlauts - Michael S. - 12-11-2008

I'll ask the user who reported this issue about that.


RE: my_substr(): Problem with umlauts - Michael S. - 12-12-2008

You're right, the mbstring module is not enabled on his host.


RE: my_substr(): Problem with umlauts - Ryan Gordon - 12-30-2008

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


RE: my_substr(): Problem with umlauts - Ryan Gordon - 01-22-2009

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.

Ryan


RE: my_substr(): Problem with umlauts - frostschutz - 01-23-2009

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.