PHP Classes
elePHPant
Icontem

Character Set From String: Identify predominant character set in a string

Recommend this page to a friend!
  Info   View files Documentation   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2018-03-20 (5 months ago) RSS 2.0 feedNot enough user ratingsTotal: 94 All time: 9,026 This week: 507Up
Version License PHP version Categories
charset-from-string 1.0.3Custom (specified...5Localization, PHP 5, Text processing, L...
Description Author

This class can identify predominant character set in a string.

It can take a string of text in UTF-8 and analyzes the character codes to determine which is the predominant character set that the is used based on the frequency of the characters that are typically of certain languages.

Currently it can identify the character sets of Latin, Greek, Cyrillic. Armenian, Hebrew, Arabic, Devanagari, Bengali, Gujarati, Tamil, Malayalam, Sinhala, Thai, Lao, Tibetan, Burmese, Georgian, Korean, Khmer, Japanese, and CJK.

Innovation Award
PHP Programming Innovation award nominee
June 2017
Number 6
A string in Unicode may contain text of multiple character sets.

This class can identify predominant character set in a string of many possible character sets.

Manuel Lemos
  Performance   Level  
Name: Peter Kahl <contact>
Classes: 34 packages by
Country: United Kingdom United Kingdom
Age: ???
All time rank: 57929 in United Kingdom United Kingdom
Week rank: 8 Up1 in United Kingdom United Kingdom Up
Innovation award
Innovation award
Nominee: 20x

Winner: 1x

Details

Charset From String

Identifies predominant script (charset, language) in a string. This library is capable of identifying:

<pre> Arabic Armenian Bengali Burmese CJK Cyrillic Devanagari Georgian Greek Gujarati Hebrew Japanese Khmer Korean Lao Latin Malayalam Sinhala Tamil Thai Tibetan </pre>

Usage

use peterkahl\CharsetFromString\CharsetFromString;

echo CharsetFromString::getCharset('?? ????? ??????'); # ARABIC

echo CharsetFromString::getCharset('????? ??? ????????'); # HEBREW

echo CharsetFromString::getCharset('?????????? ??????????? ?????????? ??????'); # CYRILLIC

echo CharsetFromString::getCharset('impeach Trump'); # LATIN

echo CharsetFromString::getCharset('????? ??? ??? ??'); # KOREAN

echo CharsetFromString::getCharset('???????????'); # JAPANESE

echo CharsetFromString::getCharset('????????'); # CJK

echo CharsetFromString::getCharset('?????????????????????????'); # THAI

echo CharsetFromString::getCharset('???????????????????????????'); # LAO

echo CharsetFromString::getCharset('?????????????????????????????????'); # KHMER

echo CharsetFromString::getCharset('???????????????????????????????????????????????????????????????????????????'); # TIBETAN

echo CharsetFromString::getCharset('?????????? ??? ????????? ??? ?????????? ????'); # GREEK
  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file CharsetFromString.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:94
This week:0
All time:9,026
This week:507Up