UCS-2 is a character encoding standard in which characters are represented by a fixed-length 16 bits (2 bytes). It is used as a fallback on many GSM networks when a message cannot be encoded using GSM-7 or when a language requires more than 128 characters to be rendered. The Basics of UCS-2 Encoding and SMS Messages
UTF-8 encoding is a variable sized encoding scheme to represent unicode code points in memory. Variable sized encoding means the code points are represented using 1, 2, 3 or 4 bytes depending on their size. A 1 byte encoding is identified by the presence of 0 in the first bit. The English alphabet A has unicode code point U+0041.
The following PHP function UTF2UCS converts the string encoding from UTF-8 to UCS-2. Text/string encoding is often required when you migrate the Database.
For example:
echo UTF2UCS("Hello, World!");
This prints:
hello 2c00 2000 world 2100
--EOF (The Ultimate Computing & Technology Blog) --
285 words
Last Post: Teaching Kids Programming - Three Consecutive Odds
Next Post: Teaching Kids Programming - Sum of Two Numbers Less Than Target using Two Pointer Algorithm