本文整理汇总了PHP中recode_string函数的典型用法代码示例。如果您正苦于以下问题:PHP recode_string函数的具体用法?PHP recode_string怎么用?PHP recode_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了recode_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: charset_decode_gb18030
/**
* 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('"', '<', '>', '&'), 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('"', '<', '>', '&'), 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;
}
示例2: charset_decode_euc_kr
/**
* 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('"', '<', '>', '&'), 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('"', '<', '>', '&'), 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;
}
示例3: toXML
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;
}
示例4: bbc_convert_keys
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;
}
}
示例5: mb_convert_encoding
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);
}
示例6: transliterate
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;
}
}
示例7: toXML
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;
}
示例8: toXML
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;
}
示例9: convertCharset
/**
* 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?');
}
示例10: utf7_decode_string
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'];
}
}
}
示例11: toXML
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;
}
示例12: toXML
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;
}
示例13: toXML
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";
//.........这里部分代码省略.........
示例14: utf8tolocal
/**
* @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;
}
示例15: toXML
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;
}