2

In my model i get content of input search, i just want to clean accented characters before doing a query. In Joomla! is-there a method to clean in string the accented characters ?

Thanks by advance

1 Answer 1

3
use Joomla\CMS\Factory;
....
        $lang = Factory::getLanguage();
        $lang->transliterate($value);
 * This method processes a string and replaces all accented UTF-8 characters by unaccented
 * ASCII-7 "equivalents".

Or check the method code to be more granular: libraries/src/Language/Language.php

    public function transliterate($string)
    {
        if ($this->transliterator !== null)
        {
            return call_user_func($this->transliterator, $string);
        }

        $string = Transliterate::utf8_latin_to_ascii($string);
        $string = StringHelper::strtolower($string);

        return $string;
    }

So you may go with

$string = Joomla\CMS\Language\Transliterate::utf8_latin_to_ascii($string);
1
  • Thanks it does the trick Commented Aug 15, 2020 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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