public static function getUnicodeEntities($text, $inCharset)
    {
        if ($inCharset != 'UTF-8') {
            if (extension_loaded('iconv')) {
                $text = iconv($inCharset, 'UTF-8//TRANSLIT', $text);
            }
            else {
                throw new PHPRtfLite_Exception('Iconv extension is not available! '
                                             . 'Activate this extension or use UTF-8 encoded texts!');
            }
        }
        $text = self::utf8ToUnicode($text);
        return self::unicodeToEntitiesPreservingAscii($text);
    }