When it is necessary to combine text that uses multiple character sets in the same document, using Unicode is often the only solution that can be used, as it includes all the text characters of most of the idioms used in the world. UTF-8 is an ASCII compatible encoding for 8 bit character texts.
PHP has functions to convert between ISO Latin 1 and UTF-8. To make conversions between other character sets it is necessary to use the multi-byte text string extension.
This class provides an alternative solution to implement the conversion of text in any character set to UTF-8 and vice-versa. It does not rely on special extensions and can be used in practically any PHP version.
This class is meant to convert text encoded as single byte string encodings such as CP1251 to UTF-8 multibyte format and vice versa.
The class loads character set from mapping files. Please access ftp://ftp.unicode.org/Public/MAPPINGS/ to obtain the mapping files that you need.
The directory from where the map files may be loaded is pre-configured in the class. Each supported character set is also pre-configured in the class to point to the respective mapping file.
The error handling function onError may be overriden in a subclass if necessary.