I have just uploaded the next version of the Portable UTF-8, PHP unicode library. This version adds 9 UTF-8 string functions to the library. There are a few bug fixes, and also some performance optimizations, but the release was mainly to extend the functionality of the library.
You can download the new version here and the detailed explanations of all functions is available here.
New Functions:
utf8_string
– Makes a string from UTF-8 code points.utf8_substr_count
– Count the number of sub string occurrences. Replacement forsubstr_count
.is_ascii
– Checks if a string is 7 bit ASCII.utf8_range
– Returns an array of characters between two codepoints (int or hex) or UTF8 characters. Replacement forrange
.utf8_hash
– Generates a hash/string of random UTF-8 characters.utf8_chr_map
– Applies callback to all UTF-8 characters.utf8_access
– Provides a way to access individual UTF-8 characters. Replacement for
$string[$i]
.utf8_str_sort
– Sort ascending/descending with respect to codepoints of all characters.utf8_strip_tags
– Replacement for PHP’sstrip_tags
.
Optimizations & Improvements:
utf8_bom
now in-lines the BOM string instead of creating the string usingpack
and caching it as astatic
variable.utf8_chr
now accepts hexadecimal codepoints.utf8_split
has been improved. New version uses PCRE and is better and faster.utf8_substr
– improved consistency withsubstr
.
Bug Fixes:
extension_loaded
was misspelled asextension_loded
in v 1.1 Line 50 – reported by Goran Jurić.