If you ever had to build a site in a language that had special characters or a multilanguage website, then you have had problems with UTF encoding for sure.
Well recently a new class was published on phpclasses.org by Rubens Takiguti Ribeiro called Unicode Manipulation that will solve your problems.
The class is a complete solution to manipulate Unicode encoded text with support for UTF-16 and UTF-32 besides UTF-8.
This class can be used to manipulate text with Unicode encodings.
It can perform several types of operations that involve text strings encoded as UTF-8, UTF-16 or UTF-32, like:
- Get the text sequence for byte order mark for little and big endian
- Convert a given character code to Unicode encoded text and vice-versa
- Get the byte length of a given Unicode encoded character
- Convert text encoding between UTF-8, UTF-16 and UTF-32
- Get a part of an Unicode encoded string from a given position and an optional length
- Get the string length of an Unicode encoded text
- Determine whether a given string has Unicode encoded text
Hope you find it usefull,