×i¼oµ¥µÄ½¨
<?php
$str = "£°£±£²£³£Á£Â£Ã£Ä£Æ£×£Ó£Ü£¢£¬£®£¿£¼£¾£u£ý£Û£Ý£ª£¦£Þ£¥£££À£¡¡«£¨£(C)£«££u£º£»";
echo "$str";
echo "<br />";
$str = preg_replace('/\xa3([\xa1-\xfe])/e', 'chr(ord(\1)-0x80)', $str);
echo $str;
ÕaÊÇÍøÉÏ¿´À´µÄ´uÂe£¬ËuÓеÄÖÐÎıeµaµÄµÚ¶þ¸o×Ö½Ú¼oÈ¥0X80£¨¼´128£(C)ËuµÃµÄÊý×Ö¾ÍÊÇ°e½ÇËuµÃµÄÊý×ÖÁË¡£¶ø/eģʽ±i´iµÄÊÇ£ºÈç¹uÉe¶¨ÁË´ËÐÞÕýu£¬preg_replace() ÔÚÌae»»×Öu´®ÖжÔÄaeÏoÒýÓÃ×÷Õý³£µÄÌae»»£¬½«Æa×÷Ϊ PHP ´uÂeÇoÖµ£¬²¢ÓÃÆa½a¹uÀ´Ìae»»ËuËÑË÷µÄ×Ö*u´®¡£
ÔÚÇUTF-8ģʽÏÂÕa¸oº¯ÊýÊÇ¿ÉÐеÄ,µ«ÊÇUTF-8Ï Õa¸o½*¨¾ÍËƺoÎÞЧ,
½¨¶þ£º
$queue = Array('£°' => '0', '£±' => '1', '£²' => '2', '£³' => '3', '£´' => '4', '£µ' => '5', '£¶' => '6', '£*' => '7', '£¸' => '8', '£¹' => '9',
'£Á' => 'A', '£Â' => 'B', '£Ã' => 'C', '£Ä' => 'D', '£Å' => 'E', '£Æ' => 'F', '£Ç' => 'G', '£È' => 'H', '£É' => 'I', '£Ê' => 'J',
'£Ë' => 'K', '£Ì' => 'L', '£Í' => 'M', '£Î' => 'N', '£Ï' => 'O', '£Ð' => 'P', '£Ñ' => 'Q', '£Ò' => 'R', '£Ó' => 'S', '£Ô' => 'T',
'£Õ' => 'U', '£Ö' => 'V', '£×' => 'W', '£Ø' => 'X', '£Ù' => 'Y', '£Ú' => 'Z', '£a' => 'a', '£a' => 'b', '£a' => 'c', '£a' => 'd',
'£a' => 'e', '£ae' => 'f', '£ç' => 'g', '£e' => 'h', '£e' => 'i', '£e' => 'j', '£e' => 'k', '£i' => 'l', '£i' => 'm', '£i' => 'n',
'£i' => 'o', '£ð' => 'p', '£ñ' => 'q', '£o' => 'r', '£o' => 's', '£o' => 't', '£o' => 'u', '£o' => 'v', '£÷' => 'w', '£ø' => 'x',
'£u' => 'y', '£u' => 'z');
echo preg_replace_callback("/([\xEF][\xBC][\x90-\x99]|[\xEF][\xBD][\x81-\x9A\xA1-\xBA])/", 'next_fchar', '£°');
function next_fchar($matches){
global $queue;
return $queue[$matches[1]];
}
½¨Èý£º
/**
* ×Ö*u´®°e½ÇºÍÈ«½Ç¼aÏa»¥×ª»»
* @param string $str ´ýת»»µÄ×Ö*u´®
* @param int $type TODBC:ת»»Îª°e½Ç£»TOSBC£¬×ª»»ÎªÈ«½Ç
* @return string *µ»Øת»»ºoµÄ×Ö*u´®
*/
function convertStrType($str, $type) {
$dbc = array(
'£°' , '£±' , '£²' , '£³' , '£´' ,
'£µ' , '£¶' , '£*' , '£¸' , '£¹' ,
'£Á' , '£Â' , '£Ã' , '£Ä' , '£Å' ,
'£Æ' , '£Ç' , '£È' , '£É' , '£Ê' ,
'£Ë' , '£Ì' , '£Í' , '£Î' , '£Ï' ,
'£Ð' , '£Ñ' , '£Ò' , '£Ó' , '£Ô' ,
'£Õ' , '£Ö' , '£×' , '£Ø' , '£Ù' ,
'£Ú' , '£a' , '£a' , '£a' , '£a' ,
'£a' , '£ae' , '£ç' , '£e' , '£e' ,
'£e' , '£e' , '£i' , '£i' , '£i' ,
'£i' , '£ð' , '£ñ' , '£o' , '£o' ,
'£o' , '£o' , '£o' , '£÷' , '£ø' ,
'£u' , '£u' , '£' , '¡¡' , '£º' ,
'£®' , '£¬' , '£¯' , '£¥' , '££' ,
'£¡' , '£À' , '£¦' , '£¨' , '£(C)' ,
'£¼' , '£¾' , '£¢' , '£§' , '£¿' ,
'£Û' , '£Ý' , '£u' , '£ý' , '£Ü' ,
'£u' , '£«' , '£½' , '£ß' , '£Þ' ,
'£¤' , '£þ' , '£a'
);
$sbc = array( //°e½Ç
'0', '1', '2', '3', '4',
'5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y',
'Z', 'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x',
'y', 'z', '-', ' ', ':',
'.', ',', '/', '%', ' #',
'!', '@', '&', '(', ')',
'<', '>', '"', '\'','?',
'[', ']', '{', '}', '\\',
'|', '+', '=', '_', '^',
'£¤','~', '`'
);
if($type == 'TODBC'){
return str_replace( $sbc, $dbc, $str ); //°e½Çµ½È«½Ç
}elseif($type == 'TOSBC'){
return str_replace( $dbc, $sbc, $str ); //È«½Çµ½°e½Ç
}else{
return $str;
}
}
½¨ËÄ£º
/**
* ½«Ò»¸o×Ö´®Öк¬ÓÐÈ«½ÇµÄÊý×Ö×Ö*u¡¢×Öĸ¡¢¿Õ¸ñ»o'%+-()'×Ö*uת»»ÎªÏaÓ¦°e½Ç×Ö*u
*
* @access public
* @param string $str ´ýת»»×Ö´®
*
* @return string $str ´¦Àiºo×Ö´®
*/
function make_semiangle($str)
{
$arr = array('£°' => '0', '£±' => '1', '£²' => '2', '£³' => '3', '£´' => '4',
'£µ' => '5', '£¶' => '6', '£*' => '7', '£¸' => '8', '£¹' => '9',
'£Á' => 'A', '£Â' => 'B', '£Ã' => 'C', '£Ä' => 'D', '£Å' => 'E',
'£Æ' => 'F', '£Ç' => 'G', '£È' => 'H', '£É' => 'I', '£Ê' => 'J',
'£Ë' => 'K', '£Ì' => 'L', '£Í' => 'M', '£Î' => 'N', '£Ï' => 'O',
'£Ð' => 'P', '£Ñ' => 'Q', '£Ò' => 'R', '£Ó' => 'S', '£Ô' => 'T',
'£Õ' => 'U', '£Ö' => 'V', '£×' => 'W', '£Ø' => 'X', '£Ù' => 'Y',
'£Ú' => 'Z', '£a' => 'a', '£a' => 'b', '£a' => 'c', '£a' => 'd',
'£a' => 'e', '£ae' => 'f', '£ç' => 'g', '£e' => 'h', '£e' => 'i',
'£e' => 'j', '£e' => 'k', '£i' => 'l', '£i' => 'm', '£i' => 'n',
'£i' => 'o', '£ð' => 'p', '£ñ' => 'q', '£o' => 'r', '£o' => 's',
'£o' => 't', '£o' => 'u', '£o' => 'v', '£÷' => 'w', '£ø' => 'x',
'£u' => 'y', '£u' => 'z',
'£¨' => '(', '£(C)' => ')', '¡²' => '[', '¡³' => ']', '¡¾' => '[',
'¡¿' => ']', '¡¼' => '[', '¡½' => ']', '¡°' => '[', '¡±' => ']',
'¡®' => '[', ''' => ']', '£u' => '{', '£ý' => '}', '¡¶' => '<',
'¡*' => '>',
'£¥' => '%', '£«' => '+', '¡ª' => '-', '£' => '-', '¡«' => '-',
'£º' => ':', '¡£' => '.', '¡¢' => ',', '£¬' => '.', '¡¢' => '.',
'£»' => ',', '£¿' => '?', '£¡' => '!', '¡' => '-', '¡¬' => '|',
'¡±' => '"', ''' => '`', '¡®' => '`', '£u' => '|', '¡¨' => '"',
'¡¡' => ' ');
return strtr($str, $arr);
}
È«½ÇÓe°e½ÇÖ®Çø±ð£¨À´×ÔÖÐÎÄά»u°Ù¿Æ£(C)
È«½Ç£¬ÓÖ³ÆÈ«ÐΡ¢È«¿i£¬ÊǵçÄÔ×ÖuµÄÒ»ÖÖ¸ñʽ£¬×ÖÃaeÒa˼ÊDZÈÆÕͨ×Öu£¨»o°e½Ç×Öu£(C)¿iµÄ×Öu¡£
´«Í³ÉÏ£¬Ó¢Ói»oÀ¶¡×ÖĸÓiÑÔʹÓÃÒ»×ֽڵĿռaÀ´´ae´¢£¬¶øºº×Ö¡¢ÈÕÓiµÈ³£Ê¹ÓÃÁ½×Ö½Ú´ae´¢£¬ÔÚʹÓù̶¨¿i¶ÈÎÄ×ֵĵؽ£¬ÎªÁËʹ×ÖÌa¿´ÆðÀ´ÕuÆe£¬Ó¢ÎÄ×Öĸ¡¢Êý×Ö¼°ÆaËuuºÅ£¬Ò²ÓÉÔÀ´Ö»Õ¼ÓÃÒ»¸o×Ö¿Õ¼a£¬¸ÄΪһ¸ÅÕ¼ÓÃÁ½¸o×ֵĿռaÀ´ÏÔʾ£¬²¢ÇÒʹÓÃÁ½¸o×Ö½ÚÀ´´ae´¢¡£
ÒÔÉÏËuÊo¾ÍÊDZ¾ÎĵÄÈ«²¿ÄÚÈÝÁË£¬Ï£Íu´o¼ÒÄܹ»Ï²»¶¡£