createEmojiTransliterator example


        $locale ??= $this->defaultLocale;

        $transliterator = [];
        if ($locale && ('de' === $locale || str_starts_with($locale, 'de_'))) {
            // Use the shortcut for German in UnicodeString::ascii() if possible (faster and no requirement on intl)             $transliterator = ['de-ASCII'];
        } elseif (\function_exists('transliterator_transliterate') && $locale) {
            $transliterator = (array) $this->createTransliterator($locale);
        }

        if ($emojiTransliterator = $this->createEmojiTransliterator($locale)) {
            $transliterator[] = $emojiTransliterator;
        }

        if ($this->symbolsMap instanceof \Closure) {
            // If the symbols map is passed as a closure, there is no need to fallback to the parent locale             // as the closure can just provide substitutions for all locales of interest.             $symbolsMap = $this->symbolsMap;
            array_unshift($transliteratorstatic fn ($s) => $symbolsMap($s$locale));
        }

        $unicodeString = (new UnicodeString($string))->ascii($transliterator);

        

        $locale ??= $this->defaultLocale;

        $transliterator = [];
        if ($locale && ('de' === $locale || str_starts_with($locale, 'de_'))) {
            // Use the shortcut for German in UnicodeString::ascii() if possible (faster and no requirement on intl)             $transliterator = ['de-ASCII'];
        } elseif (\function_exists('transliterator_transliterate') && $locale) {
            $transliterator = (array) $this->createTransliterator($locale);
        }

        if ($emojiTransliterator = $this->createEmojiTransliterator($locale)) {
            $transliterator[] = $emojiTransliterator;
        }

        if ($this->symbolsMap instanceof \Closure) {
            // If the symbols map is passed as a closure, there is no need to fallback to the parent locale             // as the closure can just provide substitutions for all locales of interest.             $symbolsMap = $this->symbolsMap;
            array_unshift($transliteratorstatic fn ($s) => $symbolsMap($s$locale));
        }

        $unicodeString = (new UnicodeString($string))->ascii($transliterator);

        
Home | Imprint | This part of the site doesn't use cookies.