Tham khảo tài liệu 'mastering joomla! extension and framework development phần 2', công nghệ thông tin, quản trị mạng phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 2 When dealing with English characters UTF-8 uses the same encodings as ASCII and ANSII. This has a purposeful consequence UTF-8 encoded strings that use these characters appear identical to their ASCII and ANSII alternatives. Applications that are Unicode unaware are therefore able to handle many UTF-8 strings. One such application that is not Unicode aware is PHP. We therefore have to be careful when manipulating strings. PHP assumes all characters are eight bits one byte but because UTF-8 encoded characters can be longer this can cause corruption of Unicode data. There is a PHP module mbstring which adds support for multi-byte character encodings unfortunately not all PHP systems have the mbstring module. In Joomla we are provided with the static JString class this class allows us to perform many of the normal string manipulation functions with UTF-8 characters. This example demonstrates how we can use JString to convert a string to upper case. Note that the method name is identical to the PHP function we would normally use string JString strtoupper string The following table describes the PHP string functions and the corresponding JString methods PHP Function JString method Description strpos strpos Finds the first occurrence of a string in a string. substr substr Gets a portion of a string. strtolower strtolower Converts a string to lowercase. strtoupper strtoupper Converts a string to uppercase. strlen strlen Counts the length of a string. str_ireplace str_ireplace Substitutes occurrences of a string with another string in a string case insensitive . str_split str_split Splits a string into an array. strcasecmp strcasecmp Compares strings. strcspn strcspn Gets the length of the string before characters from the other parameters are found. stristr stristr Finds the first occurrence of a string in a string case insensitive . strrev strrev Reverses a string. strspn strspn Counts the longest segment of a string containing specified characters. .