1

The StringHelper::normalizeKeywords() doesn't work as I expected.

When I normalize überblick it leads to the expected result:

StringHelper::normalizeKeywords('überblick') -> ueberblick

But when I normalize ÜBERBLICK I expect it also to be ueberblick but it actually returns überblick.

It could be fixed by adding the missing ASCII mappings (e.g. 196 => 'Ae') to the StringHelper::getAsciiCharMap() method or converting the string to lowercase before replacing the characters in StringHelper::normalizeKeywords() on lines 358 - 362:

-> switch these two lines:

// Remove punctuation and diacritics
$str = strtr($str, static::_getCharMap());

// Normalize to lowercase
$str = StringHelper::toLowerCase($str);
1
  • This sounds like a bug... I'd recommend reporting this directly to support@craftcms.com – Lindsey D Jun 30 '16 at 16:53
1

This may be a bug, and is probably worth reporting to P&T.

However, it's very difficult (if not impossible) for them to account for every potential ASCII character mapping for every possible language. For that reason, there is a customAsciiCharMappings config setting, which you can use as a workaround.

1
  • Ok I'll report it. For now I just lowercase the string before passing it to the normalize method to get the correct result. – oncode Jun 30 '16 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.