コード例 #1
0
ファイル: AJAXChatEncoding.php プロジェクト: Sywooch/forums
 public static function htmlEncode($str, $contentCharset = 'UTF-8')
 {
     switch ($contentCharset) {
         case 'UTF-8':
             // Encode only special chars (&, <, >, ', ") as entities:
             return AJAXChatEncoding::encodeSpecialChars($str);
             break;
         case 'ISO-8859-1':
         case 'ISO-8859-15':
             // Encode special chars and all extended characters above ISO-8859-1 charset as entities, then convert to content charset:
             return AJAXChatEncoding::convertEncoding(AJAXChatEncoding::encodeEntities($str, 'UTF-8', array(0x26, 0x26, 0, 0xffff, 0x3c, 0x3c, 0, 0xffff, 0x3e, 0x3e, 0, 0xffff, 0x27, 0x27, 0, 0xffff, 0x22, 0x22, 0, 0xffff, 0x100, 0x2ffff, 0, 0xffff)), 'UTF-8', $contentCharset);
             break;
         default:
             // Encode special chars and all characters above ASCII charset as entities, then convert to content charset:
             return AJAXChatEncoding::convertEncoding(AJAXChatEncoding::encodeEntities($str, 'UTF-8', array(0x26, 0x26, 0, 0xffff, 0x3c, 0x3c, 0, 0xffff, 0x3e, 0x3e, 0, 0xffff, 0x27, 0x27, 0, 0xffff, 0x22, 0x22, 0, 0xffff, 0x80, 0x2ffff, 0, 0xffff)), 'UTF-8', $contentCharset);
     }
 }
コード例 #2
0
 function encodeEntities($str, $encoding = 'UTF-8', $convmap = null)
 {
     return AJAXChatEncoding::encodeEntities($str, $encoding, $convmap);
 }