28
Apr
Written by: Jonathan Maron. Stored in: LiveDocx, Samples.

Many languages have special characters in addition to the 26 letters of the English alphabet.

For example, the following characters are part of the French alphabet:

À à Â â Æ æ Ç ç È è É é Ê ê Ë ë Î î Ï ï Ô ô Œ œ Ù ù Û û Ü ü

While the following are part of the German alphabet:

Ä ä Ö ö Ü ü ß

When assigning strings containing any special characters to phpLiveDocx (such as those listed above), it is important that the strings be UTF-8 encoded, otherwise, an exception will be thrown.

UTF-8 is a universal character encoding, which allows all languages to be stored in one single character range.

To find out in which encoding your strings are stored, use the PHP function mb_detect_encoding(). Should mb_detect_encoding() return a value that is not UTF-8 then you need to encode your strings before assigning them to phpLiveDocx. There are several ways of doing this, but the most simple is to wrap the string you want to encode in utf8_encode().

If you are working with phpLiveDocx in an IDE that allows you to set the encoding of source code files, then set this to UTF-8 too.

Bookmark and Share

Leave a Reply