© 2022. JoungKyun.Kim All rights reserved.
This program is under MPL 1.1 or GPL v2
Determine the charset of the input data with Mozilla Universal Charset Detection C/C++ library
This is php extension that is libchardet PHP frontend.
libchardet is based on Mozilla Universal Charset Detection C/C++ library and, detects the character set used to encode data.
This module is a c-binding, is much faster than the other chardet packages taht is made by PHP code.
mod_chardet extension supports three method for detecting charset. Supporting method and required library is as follow:
- libchardet - Mozilla Universal Charset Detect C/C++ library
- ICU - IBM International Components for Unicode
- python-chardet - Mozilla Universal Charset Detect with pure python
For CJKV(Chinese, Japanese, Korean, Vitenams) languages, recommended to use MUCD(Mozilla Universal Charset Detect). This method is best. And, about single byte languages, MUCD and ICU all best.
In the case of python-chardet mode, even use the MUCD. However, the call performance is very not good. The mode is support for test, so when if you don't give configure options, this mode does not work basically.
For more informations, see also Reference document.
- https://github.com/OOPS-ORG-PHP/mod_chardet/releases
- Inforamtion of latest version
- For PHP 7 and after: 1.0.2
- For PHP 5 and before: 0.0.5
- mod_chardet versions
- PHP 7 and after : mod_chardet >= 1.0.0
- PHP 5 ans before : mod_chardet < 1.0.0
- PHP >= 4.1
- libchardet >= 1.0.5
- libicu (optional)
- python-chardet (optional)
First, check libraries about libchardet, libicu and python-chardet.
You must install one of libchardet or libicu.
The function of python-chardet is for checking result with python-chardet. The performance of this feature is not very good and we don't recommand to use this feature.
[root@host mod_chardet]$ phpize
[root@host mod_chardet]$ ./configure --help
...
--enable-moz-chardet Support Mozilla chardet [default=yes]
--enable-icu-chardet Support ICU chardet [default=yes]
--enable-py-chardet Support python chardet [default=no]
...
[root@host mod_chardet]$ ./configure
[root@host mod_chardet]$ make && make install
add DSO extension config to your php.ini
extension = chardet.so
See also sample script of repository.