Ejemplo n.º 1
0
/**
 * Decode gb18030 encoded string
 * @param string $string gb18030 string
 * @param boolean $save_html don't html encode special characters if true
 * @return string $string decoded string
 */
function charset_decode_gb18030($string, $save_html = false)
{
    // global $aggressive_decoding;
    // don't do decoding when there are no 8bit symbols
    if (!sq_is8bit($string, 'gb18030')) {
        return $string;
    }
    // this is CPU intensive task. Use recode functions if they are available.
    if (function_exists('recode_string')) {
        // if string is already sanitized, undo htmlspecial chars
        if (!$save_html) {
            $string = str_replace(array('&quot;', '&lt;', '&gt;', '&amp;'), array('"', '<', '>', '&'), $string);
        }
        $string = recode_string("gb18030..html", $string);
        // if string sanitizing is not needed, undo htmlspecialchars applied by recode.
        if ($save_html) {
            $string = str_replace(array('&quot;', '&lt;', '&gt;', '&amp;'), array('"', '<', '>', '&'), $string);
        }
        return $string;
    }
    /*
     * iconv does not support html target, but internal utf-8 decoding is faster 
     * than pure php implementation. 
     */
    if (function_exists('iconv') && file_exists(SM_PATH . 'functions/decode/utf_8.php')) {
        include_once SM_PATH . 'functions/decode/utf_8.php';
        $string = iconv('gb18030', 'utf-8', $string);
        return charset_decode_utf_8($string);
    }
    // mbstring does not support gb18030
    // pure php decoding is not implemented.
    return $string;
}
Ejemplo n.º 2
0
/**
 * Decode euc-kr encoded string
 * @param string $string euc-kr string
 * @param boolean $save_html don't html encode special characters if true
 * @return string $string decoded string
 */
function charset_decode_euc_kr($string, $save_html = false)
{
    // global $aggressive_decoding;
    // don't do decoding when there are no 8bit symbols
    if (!sq_is8bit($string, 'euc-kr')) {
        return $string;
    }
    // this is CPU intensive task. Use recode functions if they are available.
    if (function_exists('recode_string')) {
        // if string is already sanitized, undo htmlspecial chars
        if (!$save_html) {
            $string = str_replace(array('&quot;', '&lt;', '&gt;', '&amp;'), array('"', '<', '>', '&'), $string);
        }
        $string = recode_string("euc-kr..html", $string);
        // if string sanitizing is not needed, undo htmlspecialchars applied by recode.
        if ($save_html) {
            $string = str_replace(array('&quot;', '&lt;', '&gt;', '&amp;'), array('"', '<', '>', '&'), $string);
        }
        return $string;
    }
    /*
     * iconv does not support html target, but internal utf-8 decoding is faster 
     * than pure php implementation. 
     */
    if (function_exists('iconv') && file_exists(SM_PATH . 'functions/decode/utf_8.php')) {
        include_once SM_PATH . 'functions/decode/utf_8.php';
        $string = iconv('euc-kr', 'utf-8', $string);
        return charset_decode_utf_8($string);
    }
    // try mbstring
    if (function_exists('mb_convert_encoding') && function_exists('sq_mb_list_encodings') && check_php_version(4, 3, 0) && in_array('euc-kr', sq_mb_list_encodings())) {
        return mb_convert_encoding($string, 'HTML-ENTITIES', 'EUC-KR');
    }
    return $string;
}
Ejemplo n.º 3
0
 public function toXML($recursive = false)
 {
     $XML = '<privilege:group id="' . $this->id . '" suid="' . $this->guid . '">';
     if ($this->_name !== null) {
         $XML .= recode_string("utf8..xml", $this->_name);
     }
     $XML .= "</privilege:group>";
     return $XML;
 }
Ejemplo n.º 4
0
function bbc_convert_keys($str, $from, $to)
{
    if ($from !== false && defined("_BBC_MBSTRING") && preg_match(":iso-8859-|EUC-(JP|KR)|gb2312:", $to) || !empty($BBC_CUSTOM_CHARSET) && stristr("UTF", $BBC_CUSTOM_CHARSET)) {
        return mb_convert_encoding($str, $to, $from);
    } elseif ($from !== false && defined("_BBC_ICONV")) {
        return iconv($from, $to . "//TRANSLIT", $str);
    } elseif (defined("_BBC_RECODE")) {
        return recode_string($to, $str);
    } else {
        return $str;
    }
}
Ejemplo n.º 5
0
/**
 * Converts encoding of text according to parameters with detected
 * conversion function.
 *
 * @param string $src_charset  source charset
 * @param string $dest_charset target charset
 * @param string $what         what to convert
 *
 * @return  string   converted text
 *
 * @access  public
 *
 */
function PMA_convert_string($src_charset, $dest_charset, $what)
{
    if ($src_charset == $dest_charset) {
        return $what;
    }
    switch ($GLOBALS['PMA_recoding_engine']) {
        case PMA_CHARSET_RECODE:
            return recode_string($src_charset . '..' . $dest_charset, $what);
        case PMA_CHARSET_ICONV:
            return iconv($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $what);
        case PMA_CHARSET_ICONV_AIX:
            return PMA_aix_iconv_wrapper($src_charset, $dest_charset . $GLOBALS['cfg']['IconvExtraParams'], $what);
        default:
            return $what;
    }
}
Ejemplo n.º 6
0
 function mb_convert_encoding($str, $to_encoding, $from_encoding)
 {
     if (function_exists('iconv')) {
         return iconv($from_encoding, $to_encoding, $str);
     }
     if (function_exists('recode_string')) {
         return recode_string("{$from_encoding}..{$to_encoding}", $str);
     }
     $to_encoding = _mb_encoding($to_encoding);
     $from_encoding = _mb_encoding($from_encoding);
     if ($from_encoding == 'ISO-8859-1' && $to_encoding == 'UTF-8') {
         return utf8_encode($str);
     }
     if ($from_encoding == 'UTF-8' && $to_encoding == 'ISO-8859-1') {
         return utf8_decode($str);
     }
     // replace higher ASCII codes by a question mark
     return preg_replace('/[\\x80-\\xff]/', '?', $str);
 }
Ejemplo n.º 7
0
 function transliterate($string)
 {
     switch ($this->_method) {
         case "none":
             return $string;
             break;
         case "iconv":
             return iconv($this->_fromCharset, $this->_toCharset, $string);
             break;
         case "utf8_decode":
             return $this->_mode == "flashtophp" ? utf8_decode($string) : utf8_encode($string);
             break;
         case "mbstring":
             return mb_convert_encoding($string, $this->_toCharset, $this->_fromCharset);
             break;
         case "recode":
             return recode_string($this->_fromCharset . ".." . $this->_toCharset, $string);
             break;
         default:
             return $string;
             break;
     }
 }
Ejemplo n.º 8
0
 public function toXML($recursive = false)
 {
     $XML = "<VA>\n";
     if ($this->_id !== null) {
         $XML .= "<id>" . $this->_id . "</id>\n";
     }
     if ($this->_name !== null) {
         $XML .= "<name>" . recode_string("utf8..xml", $this->_name) . "</name>\n";
     }
     if ($this->_appID !== null) {
         $XML .= "<appID>" . $this->_appID . "</appID>\n";
     }
     if ($this->_imglst_private !== null) {
         $XML .= "<imglst_private>" . $this->_imglst_private . "</imglst_private>\n";
     }
     if ($recursive) {
         if ($this->_application === null) {
             $this->getApplication();
         }
     }
     if (!($this->_application === null)) {
         $XML .= $this->_application->toXML();
     }
     if ($this->_guID !== null) {
         $XML .= "<guID>" . recode_string("utf8..xml", $this->_guID) . "</guID>\n";
     }
     $XML .= "</VA>\n";
     return $XML;
 }
Ejemplo n.º 9
0
 public function toXML($recursive = false)
 {
     $XML = "<UserAccountState>\n";
     if ($this->_id !== null) {
         $XML .= "<id>" . $this->_id . "</id>\n";
     }
     if ($this->_name !== null) {
         $XML .= "<name>" . recode_string("utf8..xml", $this->_name) . "</name>\n";
     }
     if ($this->_description !== null) {
         $XML .= "<description>" . recode_string("utf8..xml", $this->_description) . "</description>\n";
     }
     $XML .= "</UserAccountState>\n";
     return $XML;
 }
 /**
  * Convert the given string from one charset to another.
  * Trying to use MBString, Iconv, Recode - in that particular order.
  * @param string $string the string to convert
  * @param string $fromCharset the charset the given string is currently encoded in
  * @param string $toCharset the charset to convert to, defaults to UTF-8
  * @return string the converted string
  * @throws PListException on neither MBString, Iconv, Recode being available
  */
 public static function convertCharset($string, $fromCharset, $toCharset = 'UTF-8')
 {
     if (function_exists('mb_convert_encoding')) {
         return mb_convert_encoding($string, $toCharset, $fromCharset);
     }
     if (function_exists('iconv')) {
         return iconv($fromCharset, $toCharset, $string);
     }
     if (function_exists('recode_string')) {
         return recode_string($fromCharset . '..' . $toCharset, $string);
     }
     throw new PListException('neither iconv nor mbstring supported. how are we supposed to work on strings here?');
 }
 function utf7_decode_string($data_str)
 {
     $name = array();
     $name['folder_before'] = '';
     $name['folder_after'] = '';
     $name['translated'] = '';
     if (strstr($data_str, '}')) {
         // folder name at this stage is  {SERVER_NAME:PORT}FOLDERNAME
         // get everything to the right of the bracket "}", INCLUDES the bracket itself
         $name['folder_before'] = strstr($data_str, '}');
         // get rid of that 'needle' "}"
         $name['folder_before'] = substr($name['folder_before'], 1);
         // translate
         if (function_exists('recode_string') == False) {
             $name['folder_after'] = imap_utf7_decode($name['folder_before']);
         } else {
             // Modif UTF-8 by Sam Przyswa so now compatible with MS-Outlook and Netscape accentued folder name
             $name_tmp = str_replace("&", "+", $name['folder_before']);
             $name['folder_after'] = recode_string("UTF-7..ISO-8859-1", $name_tmp);
         }
         // "imap_utf7_decode" returns False if no translation occured (supposed to, can return identical string too)
         if ($name['folder_after'] == False || $name['folder_before'] == $name['folder_after']) {
             // no translation occured
             if ($this->debug_utf7 > 0) {
                 echo ' _ mail_dcom_base: utf7_decode_string (' . __LINE__ . '): returning unmodified name, NO decoding needed, returning feed $data_str: [' . htmlspecialchars(serialize($data_str)) . ']<br>';
             }
             return $data_str;
         } else {
             // replace old folder name with new folder name
             $name['translated'] = str_replace($name['folder_before'], $name['folder_after'], $data_str);
             if ($this->debug_utf7 > 0) {
                 echo ' _ mail_dcom_base: utf7_decode_string (' . __LINE__ . '): returning decoded name, $name[] DUMP: [' . htmlspecialchars(serialize($name)) . ']<br>';
             }
             return $name['translated'];
         }
     } else {
         // folder name at this stage is  FOLDERNAME
         // there is NO {SERVER} part in this name,
         // DOES THIS EVER HAPPEN comming *from* the server? I DO NOT THINK SO, but just in case
         // translate
         $name['translated'] = imap_utf7_decode($data_str);
         // "imap_utf7_decode" returns False if no translation occured
         if ($name['translated'] == False || $name['folder_before'] == $data_str) {
             // no translation occured
             if ($this->debug_utf7 > 0) {
                 echo ' _ mail_dcom_base: utf7_decode_string (' . __LINE__ . '): returning unmodified name, NO decoding needed, returning feed $data_str: [' . htmlspecialchars(serialize($data_str)) . ']<br>';
             }
             return $data_str;
         } else {
             if ($this->debug_utf7 > 0) {
                 echo ' _ mail_dcom_base: utf7_decode_string (' . __LINE__ . '): returning decoded name, $name[] DUMP: [' . htmlspecialchars(serialize($name)) . ']<br>';
             }
             return $name['translated'];
         }
     }
 }
Ejemplo n.º 12
0
 public function toXML($recursive = false)
 {
     $XML = "<AppTeam>\n";
     if ($this->_appID !== null) {
         $XML .= "<appID>" . $this->_appID . "</appID>\n";
     }
     if ($recursive) {
         if ($this->_application === null) {
             $this->getApplication();
         }
     }
     if (!($this->_application === null)) {
         $XML .= $this->_application->toXML();
     }
     if ($this->_id !== null) {
         $XML .= "<id>" . $this->_id . "</id>\n";
     }
     if ($this->_firstName !== null) {
         $XML .= "<firstName>" . recode_string("utf8..xml", $this->_firstName) . "</firstName>\n";
     }
     if ($this->_lastName !== null) {
         $XML .= "<lastName>" . recode_string("utf8..xml", $this->_lastName) . "</lastName>\n";
     }
     if ($this->_dateInclusion !== null) {
         $XML .= "<dateInclusion>" . recode_string("utf8..xml", $this->_dateInclusion) . "</dateInclusion>\n";
     }
     if ($this->_institution !== null) {
         $XML .= "<institution>" . recode_string("utf8..xml", $this->_institution) . "</institution>\n";
     }
     if ($this->_countryID !== null) {
         $XML .= "<countryID>" . $this->_countryID . "</countryID>\n";
     }
     if ($recursive) {
         if ($this->_country === null) {
             $this->getCountry();
         }
     }
     if (!($this->_country === null)) {
         $XML .= $this->_country->toXML();
     }
     if ($this->_positionTypeID !== null) {
         $XML .= "<positionTypeID>" . $this->_positionTypeID . "</positionTypeID>\n";
     }
     if ($recursive) {
         if ($this->_positionType === null) {
             $this->getPositionType();
         }
     }
     if (!($this->_positionType === null)) {
         $XML .= $this->_positionType->toXML();
     }
     $XML .= "</AppTeam>\n";
     return $XML;
 }
 public function toXML($recursive = false)
 {
     $XML = "<MetaPoaReleasePackage>\n";
     if ($this->_id !== null) {
         $XML .= "<id>" . $this->_id . "</id>\n";
     }
     if ($this->_poaId !== null) {
         $XML .= "<poaId>" . $this->_poaId . "</poaId>\n";
     }
     if ($recursive) {
         if ($this->_poaRelease === null) {
             $this->getPoaRelease();
         }
     }
     if (!($this->_poaRelease === null)) {
         $XML .= $this->_poaRelease->toXML();
     }
     if ($this->_pkgName !== null) {
         $XML .= "<pkgName>" . recode_string("utf8..xml", $this->_pkgName) . "</pkgName>\n";
     }
     if ($this->_pkgVersion !== null) {
         $XML .= "<pkgVersion>" . recode_string("utf8..xml", $this->_pkgVersion) . "</pkgVersion>\n";
     }
     if ($this->_pkgRelease !== null) {
         $XML .= "<pkgRelease>" . recode_string("utf8..xml", $this->_pkgRelease) . "</pkgRelease>\n";
     }
     if ($this->_pkgArch !== null) {
         $XML .= "<pkgArch>" . recode_string("utf8..xml", $this->_pkgArch) . "</pkgArch>\n";
     }
     if ($this->_pkgType !== null) {
         $XML .= "<pkgType>" . recode_string("utf8..xml", $this->_pkgType) . "</pkgType>\n";
     }
     if ($this->_pkgFilename !== null) {
         $XML .= "<pkgFilename>" . recode_string("utf8..xml", $this->_pkgFilename) . "</pkgFilename>\n";
     }
     if ($this->_pkgDescription !== null) {
         $XML .= "<pkgDescription>" . recode_string("utf8..xml", $this->_pkgDescription) . "</pkgDescription>\n";
     }
     if ($this->_pkgInstallationSize !== null) {
         $XML .= "<pkgInstallationSize>" . recode_string("utf8..xml", $this->_pkgInstallationSize) . "</pkgInstallationSize>\n";
     }
     if ($this->_pkgGroup !== null) {
         $XML .= "<pkgGroup>" . recode_string("utf8..xml", $this->_pkgGroup) . "</pkgGroup>\n";
     }
     if ($this->_pkgRequires !== null) {
         $XML .= "<pkgRequires>" . recode_string("utf8..xml", $this->_pkgRequires) . "</pkgRequires>\n";
     }
     if ($this->_pkgLicense !== null) {
         $XML .= "<pkgLicense>" . recode_string("utf8..xml", $this->_pkgLicense) . "</pkgLicense>\n";
     }
     if ($this->_pkgUrl !== null) {
         $XML .= "<pkgUrl>" . recode_string("utf8..xml", $this->_pkgUrl) . "</pkgUrl>\n";
     }
     if ($this->_pkgGeneral !== null) {
         $XML .= "<pkgGeneral>" . recode_string("utf8..xml", $this->_pkgGeneral) . "</pkgGeneral>\n";
     }
     if ($this->_pkgMisc !== null) {
         $XML .= "<pkgMisc>" . recode_string("utf8..xml", $this->_pkgMisc) . "</pkgMisc>\n";
     }
     if ($this->_pkgLevel !== null) {
         $XML .= "<pkgLevel>" . $this->_pkgLevel . "</pkgLevel>\n";
     }
     if ($this->_pkgSize !== null) {
         $XML .= "<pkgSize>" . $this->_pkgSize . "</pkgSize>\n";
     }
     if ($this->_pkgMd5Sum !== null) {
         $XML .= "<pkgMd5Sum>" . recode_string("utf8..xml", $this->_pkgMd5Sum) . "</pkgMd5Sum>\n";
     }
     if ($this->_pkgSha1Sum !== null) {
         $XML .= "<pkgSha1Sum>" . recode_string("utf8..xml", $this->_pkgSha1Sum) . "</pkgSha1Sum>\n";
     }
     if ($this->_pkgSha256Sum !== null) {
         $XML .= "<pkgSha256Sum>" . recode_string("utf8..xml", $this->_pkgSha256Sum) . "</pkgSha256Sum>\n";
     }
     if ($this->_pkgVersionIndex !== null) {
         $XML .= "<pkgVersionIndex>" . $this->_pkgVersionIndex . "</pkgVersionIndex>\n";
     }
     if ($this->_timestampInserted !== null) {
         $XML .= "<timestampInserted>" . recode_string("utf8..xml", $this->_timestampInserted) . "</timestampInserted>\n";
     }
     if ($this->_insertedBy !== null) {
         $XML .= "<insertedBy>" . $this->_insertedBy . "</insertedBy>\n";
     }
     $XML .= "</MetaPoaReleasePackage>\n";
     return $XML;
 }
Ejemplo n.º 14
0
 public function toXML($recursive = false)
 {
     $XML = "<Application>\n";
     if ($this->_id !== null) {
         $XML .= "<id>" . $this->_id . "</id>\n";
     }
     if ($this->_name !== null) {
         $XML .= "<name>" . recode_string("utf8..xml", $this->_name) . "</name>\n";
     }
     if ($this->_description !== null) {
         $XML .= "<description>" . recode_string("utf8..xml", $this->_description) . "</description>\n";
     }
     if ($this->_abstract !== null) {
         $XML .= "<abstract>" . recode_string("utf8..xml", $this->_abstract) . "</abstract>\n";
     }
     if ($this->_statusID !== null) {
         $XML .= "<statusID>" . $this->_statusID . "</statusID>\n";
     }
     if ($recursive) {
         if ($this->_status === null) {
             $this->getStatus();
         }
     }
     if (!($this->_status === null)) {
         $XML .= $this->_status->toXML();
     }
     if ($this->_dateAdded !== null) {
         $XML .= "<dateAdded>" . recode_string("utf8..xml", $this->_dateAdded) . "</dateAdded>\n";
     }
     if ($this->_addedBy !== null) {
         $XML .= "<addedBy>" . $this->_addedBy . "</addedBy>\n";
     }
     if ($recursive) {
         if ($this->_researcher === null) {
             $this->getResearcher();
         }
     }
     if (!($this->_researcher === null)) {
         $XML .= $this->_researcher->toXML();
     }
     if ($this->_respect !== null) {
         $XML .= "<respect>" . $this->_respect . "</respect>\n";
     }
     if ($this->_tool !== null) {
         $XML .= "<tool>" . $this->_tool . "</tool>\n";
     }
     if ($this->_guid !== null) {
         $XML .= "<guid>" . recode_string("utf8..xml", $this->_guid) . "</guid>\n";
     }
     if ($this->_keywords !== null) {
         $XML .= "<keywords>" . recode_string("utf8..xml", $this->_keywords) . "</keywords>\n";
     }
     if ($this->_lastUpdated !== null) {
         $XML .= "<lastUpdated>" . recode_string("utf8..xml", $this->_lastUpdated) . "</lastUpdated>\n";
     }
     if ($this->_rating !== null) {
         $XML .= "<rating>" . $this->_rating . "</rating>\n";
     }
     if ($this->_ratingCount !== null) {
         $XML .= "<ratingCount>" . $this->_ratingCount . "</ratingCount>\n";
     }
     if ($this->_moderated !== null) {
         $XML .= "<moderated>" . $this->_moderated . "</moderated>\n";
     }
     if ($this->_tagPolicy !== null) {
         $XML .= "<tagPolicy>" . $this->_tagPolicy . "</tagPolicy>\n";
     }
     if ($this->_deleted !== null) {
         $XML .= "<deleted>" . $this->_deleted . "</deleted>\n";
     }
     if ($this->_metatype !== null) {
         $XML .= "<metatype>" . $this->_metatype . "</metatype>\n";
     }
     if ($this->_disciplineID !== null) {
         $XML .= "<disciplineID>" . $this->_disciplineID . "</disciplineID>\n";
     }
     if ($this->_ownerID !== null) {
         $XML .= "<ownerID>" . $this->_ownerID . "</ownerID>\n";
     }
     if ($recursive) {
         if ($this->_owner === null) {
             $this->getOwner();
         }
     }
     if (!($this->_owner === null)) {
         $XML .= $this->_owner->toXML();
     }
     if ($this->_categoryID !== null) {
         $XML .= "<categoryID>" . $this->_categoryID . "</categoryID>\n";
     }
     if ($this->_hitcount !== null) {
         $XML .= "<hitcount>" . $this->_hitcount . "</hitcount>\n";
     }
     if ($this->_cname !== null) {
         $XML .= "<cname>" . recode_string("utf8..xml", $this->_cname) . "</cname>\n";
     }
     if ($this->_links !== null) {
         $XML .= "<links>" . recode_string("utf8..xml", $this->_links) . "</links>\n";
     }
     $XML .= "</Application>\n";
     return $XML;
 }
Ejemplo n.º 15
0
/**
 * @return $str converted UTF-8 to local encoding
/**/
function utf8tolocal($str)
{
    if (empty($_SERVER['fs_encoding'])) {
        return $str;
    }
    if (function_exists('mb_convert_encoding')) {
        return mb_convert_encoding($str, $_SERVER['fs_encoding'], 'UTF-8');
    }
    if (function_exists('iconv')) {
        return iconv('UTF-8', $_SERVER['fs_encoding'], $str);
    }
    if (function_exists('recode_string')) {
        return recode_string('UTF-8..' . $_SERVER['fs_encoding'], $str);
    }
    return $str;
}
Ejemplo n.º 16
0
 public function toXML($recursive = false)
 {
     $XML = "<ContactType>\n";
     if ($this->_id !== null) {
         $XML .= "<id>" . $this->_id . "</id>\n";
     }
     if ($this->_description !== null) {
         $XML .= "<description>" . recode_string("utf8..xml", $this->_description) . "</description>\n";
     }
     $XML .= "</ContactType>\n";
     return $XML;
 }
Ejemplo n.º 17
0
 public function toXML($recursive = false)
 {
     $XML = "<Region>\n";
     if ($this->_id !== null) {
         $XML .= "<id>" . $this->_id . "</id>\n";
     }
     if ($this->_name !== null) {
         $XML .= "<name>" . recode_string("utf8..xml", $this->_name) . "</name>\n";
     }
     $XML .= "</Region>\n";
     return $XML;
 }
Ejemplo n.º 18
0
    /**
	* AkCharset::RecodeString() recode_string implementation
	*
	* @access private
	* @see RecodeString
	* @return    string    Recoded string if possible, otherwise it will
	* return the string without modifications.
	*/
    function _RecodeStringRecode($string, $target_charset, $origin_charset)
    {
        return recode_string($target_charset, '..'.$origin_charset, $string);
    }// -- end of &_RecodeStringRecode -- //
Ejemplo n.º 19
0
 public function toXML($recursive = false)
 {
     $XML = "<UserAccount>\n";
     if ($this->_id !== null) {
         $XML .= "<id>" . $this->_id . "</id>\n";
     }
     if ($this->_researcherID !== null) {
         $XML .= "<researcherID>" . recode_string("utf8..xml", $this->_researcherID) . "</researcherID>\n";
     }
     if ($recursive) {
         if ($this->_researcher === null) {
             $this->getResearcher();
         }
     }
     if (!($this->_researcher === null)) {
         $XML .= $this->_researcher->toXML();
     }
     if ($this->_accountID !== null) {
         $XML .= "<accountID>" . recode_string("utf8..xml", $this->_accountID) . "</accountID>\n";
     }
     if ($this->_accountTypeID !== null) {
         $XML .= "<accountTypeID>" . recode_string("utf8..xml", $this->_accountTypeID) . "</accountTypeID>\n";
     }
     if ($recursive) {
         if ($this->_accountType === null) {
             $this->getAccountType();
         }
     }
     if (!($this->_accountType === null)) {
         $XML .= $this->_accountType->toXML();
     }
     if ($this->_accountname !== null) {
         $XML .= "<accountname>" . recode_string("utf8..xml", $this->_accountname) . "</accountname>\n";
     }
     if ($this->_stateID !== null) {
         $XML .= "<stateID>" . $this->_stateID . "</stateID>\n";
     }
     if ($this->_idptrace !== null) {
         $XML .= "<IDPTrace>" . $this->_idptrace . "</IDPTrace>\n";
     }
     $XML .= "</UserAccount>\n";
     return $XML;
 }
Ejemplo n.º 20
0
/**
 * Converts iso-2022-kr texts
 * @param string $string iso-2022-kr encoded string
 * @param boolean $save_html don't html encode special characters if true
 * @return string html encoded string
 */
function charset_decode_iso_2022_kr($string, $save_html = false)
{
    global $aggressive_decoding;
    // undo htmlspecial chars (they can break iso-2022-kr)
    if (!$save_html) {
        $string = str_replace(array('&quot;', '&lt;', '&gt;', '&amp;'), array('"', '<', '>', '&'), $string);
    }
    // recode
    // this is CPU intensive task. Use recode functions if they are available.
    if (function_exists('recode_string')) {
        $string = recode_string("iso-2022-kr..html", $string);
        // if string sanitizing is not needed, undo htmlspecialchars applied by recode.
        if ($save_html) {
            $string = str_replace(array('&quot;', '&lt;', '&gt;', '&amp;'), array('"', '<', '>', '&'), $string);
        }
        return $string;
    }
    // iconv does not support html target, but internal utf-8 decoding is faster than iso-2022-kr.
    if (function_exists('iconv') && file_exists(SM_PATH . 'functions/decode/utf_8.php')) {
        include_once SM_PATH . 'functions/decode/utf_8.php';
        $string = iconv('iso-2022-kr', 'utf-8', $string);
        // redo htmlspecial chars
        if (!$save_html) {
            $string = htmlspecialchars($string);
        }
        return charset_decode_utf_8($string);
    }
    // aggressive decoding disabled. iso-2022-kr is not supported by iso_2022_support.php
    //    if (! isset($aggressive_decoding) || ! $aggressive_decoding )
    return htmlspecialchars($string);
    /**
     * Include common iso-2022-xx functions
     */
    include_once SM_PATH . 'functions/decode/iso_2022_support.php';
    $index = 0;
    $ret = '';
    $enc_table = 'ascii';
    while ($index < strlen($string)) {
        if (isset($string[$index + 2]) && $string[$index] == "") {
            // table change
            switch ($string[$index] . $string[$index + 1] . $string[$index + 2]) {
                case "(B":
                    $enc_table = 'ascii';
                    $index = $index + 3;
                    break;
                case "\$B":
                    $enc_table = 'jis0208-1983';
                    $index = $index + 3;
                    break;
                case "(J":
                    $enc_table = 'jis0201-1976';
                    $index = $index + 3;
                    break;
                case "\$@":
                    $enc_table = 'jis0208-1978';
                    $index = $index + 3;
                    break;
                default:
                    return _("Unsupported ESC sequence.");
            }
        }
        $ret .= get_iso_2022_symbol($string, $index, $enc_table);
        $index = $index + get_iso_2022_symbolsize($enc_table);
    }
    return $ret;
}
Ejemplo n.º 21
0
 /**
  * Pick the best possible function to convert a strings character set, if any exist
  *
  * @param string $string
  * @param string $from
  * @param string $to
  */
 private function _charset_convert($string, $from, $to)
 {
     // Lets assume we have one of the functions available to us
     $this->_converted_utf8 = true;
     $string_save = $string;
     // Use iconv if its available
     if (function_exists('iconv')) {
         $string = @iconv($from, $to . '//TRANSLIT//IGNORE', $string);
     }
     // No iconv or a false response from it
     if (!function_exists('iconv') || $string == false) {
         // PHP (some 5.4 versions) mishandles //TRANSLIT//IGNORE and returns false: see https://bugs.php.net/bug.php?id=61484
         if ($string == false) {
             $string = $string_save;
         }
         if (function_exists('mb_convert_encoding')) {
             // Replace unknown characters with a space
             @ini_set('mbstring.substitute_character', '32');
             $string = @mb_convert_encoding($string, $to, $from);
         } elseif (function_exists('recode_string')) {
             $string = @recode_string($from . '..' . $to, $string);
         } else {
             $this->_converted_utf8 = false;
         }
     }
     unset($string_save);
     return $string;
 }
Ejemplo n.º 22
0
/**

* traitement des chaines accentuees (simpleXML recupere des chaines UTF8, meme si l'entete du XML est ISO)
* @Parametres chaine a traiter
* @Return la chaine correctement encodee

*/

function traite_utf8($chaine) {
	// On passe par cette fonction pour pouvoir desactiver rapidement ce traitement s'il ne se revele plus necessaire
	//$retour=$chaine;

	// mb_detect_encoding($chaine . 'a' , 'UTF-8, ISO-8859-1');

	//$retour=utf8_decode($chaine);
	// utf8_decode() va donner de l'iso-8859-1 d'ou probleme sur quelques caracteres

	//$retour=recode_string("utf8..lat9", $chaine);
	//Warning: recode_string(): Illegal recode request 'utf8..lat9' in /var/www/se3/includes/crob_ldap_functions.php on line 277

	$retour=recode_string("utf8..iso-8859-15", $chaine);
	return $retour;
}
Ejemplo n.º 23
0
 public function toXML($recursive = false)
 {
     $XML = "<ResearcherCname>\n";
     if ($this->_id !== null) {
         $XML .= "<id>" . $this->_id . "</id>\n";
     }
     if ($this->_created !== null) {
         $XML .= "<created>" . recode_string("utf8..xml", $this->_created) . "</created>\n";
     }
     if ($this->_enabled !== null) {
         $XML .= "<enabled>" . $this->_enabled . "</enabled>\n";
     }
     if ($this->_isprimary !== null) {
         $XML .= "<isprimary>" . $this->_isprimary . "</isprimary>\n";
     }
     if ($this->_value !== null) {
         $XML .= "<value>" . recode_string("utf8..xml", $this->_value) . "</value>\n";
     }
     if ($this->_researcherID !== null) {
         $XML .= "<researcherID>" . $this->_researcherID . "</researcherID>\n";
     }
     $XML .= "</ResearcherCname>\n";
     return $XML;
 }
Ejemplo n.º 24
0
 public function toXML($recursive = false)
 {
     $XML = "<DisciplineInfoEntry>\n";
     if ($this->_id !== null) {
         $XML .= "<id>" . $this->_id . "</id>\n";
     }
     if ($this->_disciplineID !== null) {
         $XML .= "<disciplineID>" . $this->_disciplineID . "</disciplineID>\n";
     }
     if ($recursive) {
         if ($this->_discipline === null) {
             $this->getDiscipline();
         }
     }
     if (!($this->_discipline === null)) {
         $XML .= $this->_discipline->toXML();
     }
     if ($this->_type !== null) {
         $XML .= "<type>" . $this->_type . "</type>\n";
     }
     if ($this->_data !== null) {
         $XML .= "<data>" . recode_string("utf8..xml", $this->_data) . "</data>\n";
     }
     $XML .= "</DisciplineInfoEntry>\n";
     return $XML;
 }
Ejemplo n.º 25
0
/**
 * converts charset of a mysql message, usually coming from mysql_error(),
 * into PMA charset, usally UTF-8
 * uses language to charset mapping from mysql/share/errmsg.txt
 * and charset names to ISO charset from information_schema.CHARACTER_SETS
 *
 * @uses    $GLOBALS['cfg']['IconvExtraParams']
 * @uses    $GLOBALS['charset']     as target charset
 * @uses    PMA_DBI_fetch_value()   to get server_language
 * @uses    preg_match()            to filter server_language
 * @uses    in_array()
 * @uses    function_exists()       to check for a convert function
 * @uses    iconv()                 to convert message
 * @uses    libiconv()              to convert message
 * @uses    recode_string()         to convert message
 * @uses    mb_convert_encoding()   to convert message
 * @param   string  $message
 * @return  string  $message
 */
function PMA_DBI_convert_message($message)
{
    // latin always last!
    $encodings = array('japanese' => 'EUC-JP', 'japanese-sjis' => 'Shift-JIS', 'korean' => 'EUC-KR', 'russian' => 'KOI8-R', 'ukrainian' => 'KOI8-U', 'greek' => 'ISO-8859-7', 'serbian' => 'CP1250', 'estonian' => 'ISO-8859-13', 'slovak' => 'ISO-8859-2', 'czech' => 'ISO-8859-2', 'hungarian' => 'ISO-8859-2', 'polish' => 'ISO-8859-2', 'romanian' => 'ISO-8859-2', 'spanish' => 'CP1252', 'swedish' => 'CP1252', 'italian' => 'CP1252', 'norwegian-ny' => 'CP1252', 'norwegian' => 'CP1252', 'portuguese' => 'CP1252', 'danish' => 'CP1252', 'dutch' => 'CP1252', 'english' => 'CP1252', 'french' => 'CP1252', 'german' => 'CP1252');
    if ($server_language = PMA_DBI_fetch_value('SHOW VARIABLES LIKE \'language\';', 0, 1)) {
        $found = array();
        if (preg_match('&(?:\\\\|\\/)([^\\\\\\/]*)(?:\\\\|\\/)$&i', $server_language, $found)) {
            $server_language = $found[1];
        }
    }
    if (!empty($server_language) && isset($encodings[$server_language])) {
        if (function_exists('iconv')) {
            if (@stristr(PHP_OS, 'AIX') && @strcasecmp(ICONV_IMPL, 'unknown') == 0 && @strcasecmp(ICONV_VERSION, 'unknown') == 0) {
                require_once './libraries/iconv_wrapper.lib.php';
                $message = PMA_aix_iconv_wrapper($encodings[$server_language], $GLOBALS['charset'] . $GLOBALS['cfg']['IconvExtraParams'], $message);
            } else {
                $message = iconv($encodings[$server_language], $GLOBALS['charset'] . $GLOBALS['cfg']['IconvExtraParams'], $message);
            }
        } elseif (function_exists('recode_string')) {
            $message = recode_string($encodings[$server_language] . '..' . $GLOBALS['charset'], $message);
        } elseif (function_exists('libiconv')) {
            $message = libiconv($encodings[$server_language], $GLOBALS['charset'], $message);
        } elseif (function_exists('mb_convert_encoding')) {
            // do not try unsupported charsets
            if (!in_array($server_language, array('ukrainian', 'greek', 'serbian'))) {
                $message = mb_convert_encoding($message, $GLOBALS['charset'], $encodings[$server_language]);
            }
        }
    } else {
        /**
         * @todo lang not found, try all, what TODO ?
         */
    }
    return $message;
}
Ejemplo n.º 26
0
 /**
  * Convert from one charset to another charset.
  *
  * @param	string		Input string
  * @param	string		From charset (the current charset of the string)
  * @param	string		To charset (the output charset wanted)
  * @param	boolean		If set, then characters that are not available in the destination character set will be encoded as numeric entities
  * @return	string		Converted string
  * @see convArray()
  */
 function conv($str, $fromCS, $toCS, $useEntityForNoChar = 0)
 {
     if ($fromCS == $toCS) {
         return $str;
     }
     // PHP-libs don't support fallback to SGML entities, but UTF-8 handles everything
     if ($toCS == 'utf-8' || !$useEntityForNoChar) {
         switch ($GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod']) {
             case 'mbstring':
                 $conv_str = mb_convert_encoding($str, $toCS, $fromCS);
                 if (false !== $conv_str) {
                     return $conv_str;
                 }
                 // returns false for unsupported charsets
                 break;
             case 'iconv':
                 $conv_str = iconv($fromCS, $toCS . '//TRANSLIT', $str);
                 if (false !== $conv_str) {
                     return $conv_str;
                 }
                 break;
             case 'recode':
                 $conv_str = recode_string($fromCS . '..' . $toCS, $str);
                 if (false !== $conv_str) {
                     return $conv_str;
                 }
                 break;
         }
         // fallback to TYPO3 conversion
     }
     if ($fromCS != 'utf-8') {
         $str = $this->utf8_encode($str, $fromCS);
     }
     if ($toCS != 'utf-8') {
         $str = $this->utf8_decode($str, $toCS, $useEntityForNoChar);
     }
     return $str;
 }
Ejemplo n.º 27
0
 public function toXML($recursive = false)
 {
     $XML = "<Relation>\n";
     if ($this->_id !== null) {
         $XML .= "<id>" . $this->_id . "</id>\n";
     }
     if ($this->_relTypeID !== null) {
         $XML .= "<relTypeID>" . $this->_relTypeID . "</relTypeID>\n";
     }
     if ($recursive) {
         if ($this->_relationVerb === null) {
             $this->getRelationVerb();
         }
     }
     if (!($this->_relationVerb === null)) {
         $XML .= $this->_relationVerb->toXML();
     }
     if ($this->_targetGUID !== null) {
         $XML .= "<targetGUID>" . recode_string("utf8..xml", $this->_targetGUID) . "</targetGUID>\n";
     }
     if ($this->_subjectGUID !== null) {
         $XML .= "<subjectGUID>" . $this->_subjectGUID . "</subjectGUID>\n";
     }
     if ($this->_parentID !== null) {
         $XML .= "<parentID>" . $this->_parentID . "</parentID>\n";
     }
     if ($recursive) {
         if ($this->_parent === null) {
             $this->getParent();
         }
     }
     if (!($this->_parent === null)) {
         $XML .= $this->_parent->toXML();
     }
     if ($this->_addedOn !== null) {
         $XML .= "<addedOn>" . recode_string("utf8..xml", $this->_addedOn) . "</addedOn>\n";
     }
     if ($this->_addedByID !== null) {
         $XML .= "<addedByID>" . $this->_addedByID . "</addedByID>\n";
     }
     if ($recursive) {
         if ($this->_addedBy === null) {
             $this->getAddedBy();
         }
     }
     if (!($this->_addedBy === null)) {
         $XML .= $this->_addedBy->toXML();
     }
     if ($this->_denyOn !== null) {
         $XML .= "<denyOn>" . recode_string("utf8..xml", $this->_denyOn) . "</denyOn>\n";
     }
     if ($this->_denyByID !== null) {
         $XML .= "<denyByID>" . $this->_denyByID . "</denyByID>\n";
     }
     if ($recursive) {
         if ($this->_denyBy === null) {
             $this->getDenyBy();
         }
     }
     if (!($this->_denyBy === null)) {
         $XML .= $this->_denyBy->toXML();
     }
     if ($this->_guid !== null) {
         $XML .= "<guid>" . recode_string("utf8..xml", $this->_guid) . "</guid>\n";
     }
     if ($this->_hiddenOn !== null) {
         $XML .= "<hiddenOn>" . recode_string("utf8..xml", $this->_hiddenOn) . "</hiddenOn>\n";
     }
     if ($this->_hiddenByID !== null) {
         $XML .= "<hiddenByID>" . $this->_hiddenByID . "</hiddenByID>\n";
     }
     if ($recursive) {
         if ($this->_hiddenBy === null) {
             $this->getHiddenBy();
         }
     }
     if (!($this->_hiddenBy === null)) {
         $XML .= $this->_hiddenBy->toXML();
     }
     $XML .= "</Relation>\n";
     return $XML;
 }
Ejemplo n.º 28
0
 public function toXML($recursive = false)
 {
     $XML = "<Project>\n";
     if ($this->_id !== null) {
         $XML .= "<id>" . $this->_id . "</id>\n";
     }
     if ($this->_code !== null) {
         $XML .= "<code>" . recode_string("utf8..xml", $this->_code) . "</code>\n";
     }
     if ($this->_acronym !== null) {
         $XML .= "<acronym>" . recode_string("utf8..xml", $this->_acronym) . "</acronym>\n";
     }
     if ($this->_title !== null) {
         $XML .= "<title>" . recode_string("utf8..xml", $this->_title) . "</title>\n";
     }
     if ($this->_startDate !== null) {
         $XML .= "<startDate>" . recode_string("utf8..xml", $this->_startDate) . "</startDate>\n";
     }
     if ($this->_endDate !== null) {
         $XML .= "<endDate>" . recode_string("utf8..xml", $this->_endDate) . "</endDate>\n";
     }
     if ($this->_callIdentifier !== null) {
         $XML .= "<callIdentifier>" . recode_string("utf8..xml", $this->_callIdentifier) . "</callIdentifier>\n";
     }
     if ($this->_websiteURL !== null) {
         $XML .= "<websiteURL>" . recode_string("utf8..xml", $this->_websiteURL) . "</websiteURL>\n";
     }
     if ($this->_keywords !== null) {
         $XML .= "<keywords>" . recode_string("utf8..xml", $this->_keywords) . "</keywords>\n";
     }
     if ($this->_duration !== null) {
         $XML .= "<duration>" . recode_string("utf8..xml", $this->_duration) . "</duration>\n";
     }
     if ($this->_contractTypeID !== null) {
         $XML .= "<contractTypeID>" . $this->_contractTypeID . "</contractTypeID>\n";
     }
     if ($recursive) {
         if ($this->_contractType === null) {
             $this->getContractType();
         }
     }
     if (!($this->_contractType === null)) {
         $XML .= $this->_contractType->toXML();
     }
     if ($this->_fundingID !== null) {
         $XML .= "<fundingID>" . $this->_fundingID . "</fundingID>\n";
     }
     if ($recursive) {
         if ($this->_funding === null) {
             $this->getFunding();
         }
     }
     if (!($this->_funding === null)) {
         $XML .= $this->_funding->toXML();
     }
     if ($this->_addedOn !== null) {
         $XML .= "<addedOn>" . recode_string("utf8..xml", $this->_addedOn) . "</addedOn>\n";
     }
     if ($this->_addedByID !== null) {
         $XML .= "<addedByID>" . $this->_addedByID . "</addedByID>\n";
     }
     if ($recursive) {
         if ($this->_addedBy === null) {
             $this->getAddedBy();
         }
     }
     if (!($this->_addedBy === null)) {
         $XML .= $this->_addedBy->toXML();
     }
     if ($this->_guid !== null) {
         $XML .= "<guid>" . recode_string("utf8..xml", $this->_guid) . "</guid>\n";
     }
     if ($this->_identifier !== null) {
         $XML .= "<identifier>" . recode_string("utf8..xml", $this->_identifier) . "</identifier>\n";
     }
     if ($this->_sourceID !== null) {
         $XML .= "<sourceID>" . $this->_sourceID . "</sourceID>\n";
     }
     if ($recursive) {
         if ($this->_entitysource === null) {
             $this->getEntitysource();
         }
     }
     if (!($this->_entitysource === null)) {
         $XML .= $this->_entitysource->toXML();
     }
     if ($this->_deletedon !== null) {
         $XML .= "<deletedon>" . recode_string("utf8..xml", $this->_deletedon) . "</deletedon>\n";
     }
     if ($this->_deletedby !== null) {
         $XML .= "<deletedby>" . $this->_deletedby . "</deletedby>\n";
     }
     if ($recursive) {
         if ($this->_deletedBy === null) {
             $this->getDeletedBy();
         }
     }
     if (!($this->_deletedBy === null)) {
         $XML .= $this->_deletedBy->toXML();
     }
     if ($this->_extIdentifier !== null) {
         $XML .= "<extIdentifier>" . recode_string("utf8..xml", $this->_extIdentifier) . "</extIdentifier>\n";
     }
     if ($this->_moderated !== null) {
         $XML .= "<moderated>" . $this->_moderated . "</moderated>\n";
     }
     if ($this->_deleted !== null) {
         $XML .= "<deleted>" . $this->_deleted . "</deleted>\n";
     }
     $XML .= "</Project>\n";
     return $XML;
 }
Ejemplo n.º 29
0
 /**
  * Convert from one charset to another charset.
  *
  * @param string $inputString Input string
  * @param string $fromCharset From charset (the current charset of the string)
  * @param string $toCharset To charset (the output charset wanted)
  * @param bool $useEntityForNoChar If set, then characters that are not available in the destination character set will be encoded as numeric entities
  * @return string Converted string
  * @see convArray()
  */
 public function conv($inputString, $fromCharset, $toCharset, $useEntityForNoChar = FALSE)
 {
     if ($fromCharset === $toCharset) {
         return $inputString;
     }
     // PHP-libs don't support fallback to SGML entities, but UTF-8 handles everything
     if ($toCharset === 'utf-8' || !$useEntityForNoChar) {
         switch ($GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod']) {
             case 'mbstring':
                 $convertedString = mb_convert_encoding($inputString, $toCharset, $fromCharset);
                 if (FALSE !== $convertedString) {
                     return $convertedString;
                 }
                 // Returns FALSE for unsupported charsets
                 break;
             case 'iconv':
                 $convertedString = iconv($fromCharset, $toCharset . '//TRANSLIT', $inputString);
                 if (FALSE !== $convertedString) {
                     return $convertedString;
                 }
                 break;
             case 'recode':
                 $convertedString = recode_string($fromCharset . '..' . $toCharset, $inputString);
                 if (FALSE !== $convertedString) {
                     return $convertedString;
                 }
                 break;
         }
     }
     if ($fromCharset !== 'utf-8') {
         $inputString = $this->utf8_encode($inputString, $fromCharset);
     }
     if ($toCharset !== 'utf-8') {
         $inputString = $this->utf8_decode($inputString, $toCharset, $useEntityForNoChar);
     }
     return $inputString;
 }
Ejemplo n.º 30
0
 public function toXML($recursive = false)
 {
     $XML = "<HarvestContactPerson>\n";
     if ($this->_id !== null) {
         $XML .= "<id>" . $this->_id . "</id>\n";
     }
     if ($this->_identifier !== null) {
         $XML .= "<identifier>" . recode_string("utf8..xml", $this->_identifier) . "</identifier>\n";
     }
     if ($this->_fullName !== null) {
         $XML .= "<fullName>" . recode_string("utf8..xml", $this->_fullName) . "</fullName>\n";
     }
     if ($this->_email !== null) {
         $XML .= "<email>" . recode_string("utf8..xml", $this->_email) . "</email>\n";
     }
     if ($this->_phone !== null) {
         $XML .= "<phone>" . recode_string("utf8..xml", $this->_phone) . "</phone>\n";
     }
     if ($this->_fax !== null) {
         $XML .= "<fax>" . $this->_fax . "</fax>\n";
     }
     if ($this->_researcherID !== null) {
         $XML .= "<researcherID>" . $this->_researcherID . "</researcherID>\n";
     }
     if ($recursive) {
         if ($this->_researcher === null) {
             $this->getResearcher();
         }
     }
     if (!($this->_researcher === null)) {
         $XML .= $this->_researcher->toXML();
     }
     $XML .= "</HarvestContactPerson>\n";
     return $XML;
 }