Detect language/encoding of a string in PHP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.coveralls.yml
.styleci
.travis.yml
LICENSE.md
README.md
composer.json
composer.lock
phpunit.xml

README.md

Determine Language Script of Strings

Detect if a string contains different language scripts with a simple API.

Build Status Coverage StyleCI Status Total Downloads Latest Stable Version License

Installation

You just require using composer and you're good to go!

composer require lasserafn/php-string-script-language

Usage

As with installation, usage is quite simple:

use LasseRafn\StringScript;

StringScript::isThai('Hello world.'); // false
StringScript::isChinese('你好世界。'); // true

All methods return a boolean value.

Supported scripts

  • Common
  • Arabic
  • Armenian
  • Bengali
  • Bopomofo
  • Braille
  • Buhid
  • Canadian Aboriginal
  • Cherokee
  • Cyrillic
  • Devanagari
  • Ethiopic
  • Georgian
  • Greek
  • Gujarati
  • Gurmukhi
  • Han
  • Hangul
  • Hanunoo
  • Hebrew
  • Hiragana
  • Inherited
  • Kannada
  • Katakana
  • Khmer
  • Lao
  • Latin
  • Limbu
  • Malayalam
  • Mongolian
  • Myanmar
  • Ogham
  • Oriya
  • Runic
  • Sinhala
  • Syriac
  • Tagalog
  • Tagbanwa
  • TaiLe
  • Tamil
  • Telugu
  • Thaana
  • Thai
  • Tibetan
  • Yi
  • Chinese (Helper for Han)
  • Japanese (Helper for Hiragana or Katakana)

All methods

StringScript::isCommon($string);
StringScript::isArabic($string);
StringScript::isArmenian($string);
StringScript::isBengali($string);
StringScript::isBopomofo($string);
StringScript::isBraille($string);
StringScript::isBuhid($string);
StringScript::isCanadian_Aboriginal($string);
StringScript::isCherokee($string);
StringScript::isCyrillic($string);
StringScript::isDevanagari($string);
StringScript::isEthiopic($string);
StringScript::isGeorgian($string);
StringScript::isGreek($string);
StringScript::isGujarati($string);
StringScript::isGurmukhi($string);
StringScript::isHan($string);
StringScript::isHangul($string);
StringScript::isHanunoo($string);
StringScript::isHebrew($string);
StringScript::isHiragana($string);
StringScript::isInherited($string);
StringScript::isKannada($string);
StringScript::isKatakana($string);
StringScript::isKhmer($string);
StringScript::isLao($string);
StringScript::isLatin($string);
StringScript::isLimbu($string);
StringScript::isMalayalam($string);
StringScript::isMongolian($string);
StringScript::isMyanmar($string);
StringScript::isOgham($string);
StringScript::isOriya($string);
StringScript::isRunic($string);
StringScript::isSinhala($string);
StringScript::isSyriac($string);
StringScript::isTagalog($string);
StringScript::isTagbanwa($string);
StringScript::isTaiLe($string);
StringScript::isTamil($string);
StringScript::isTelugu($string);
StringScript::isThaana($string);
StringScript::isThai($string);
StringScript::isTibetan($string);
StringScript::isYi($string);
StringScript::isChinese($string);
StringScript::isJapanese($string);

Requirements

  • PHP 5.6, 7.0 or 7.1