+
+ return array_values($blocks);
+ }
+
+ /**
+ * returns the block code for the given character
+ *
+ * @param string $character
+ * @return integer 0 = no alpha character (blank, signs, emojis, ...), 1 = latin character, 2 = character in every other language
+ */
+ private static function getBlockCode(string $character): int
+ {
+ if (!\IntlChar::isalpha($character)) {
+ return 0;
+ }
+ return self::isLatin($character) ? 1 : 2;
+ }
+
+ /**
+ * Checks if the given character is in one of the latin code blocks
+ *
+ * @param string $character
+ * @return boolean
+ */
+ private static function isLatin(string $character): bool
+ {
+ return in_array(\IntlChar::getBlockCode($character), [
+ \IntlChar::BLOCK_CODE_BASIC_LATIN, \IntlChar::BLOCK_CODE_LATIN_1_SUPPLEMENT,
+ \IntlChar::BLOCK_CODE_LATIN_EXTENDED_A, \IntlChar::BLOCK_CODE_LATIN_EXTENDED_B,
+ \IntlChar::BLOCK_CODE_LATIN_EXTENDED_C, \IntlChar::BLOCK_CODE_LATIN_EXTENDED_D,
+ \IntlChar::BLOCK_CODE_LATIN_EXTENDED_E, \IntlChar::BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL
+ ]);