Ejemplo n.º 1
0
 /**
  * Encodes every character in the string to HTML Encoded characters,
  * this is multibyte save
  * @param string $string String to encode
  * @see htmlOrdDecode
  * @return string
  */
 public static function htmlOrdEncode($string)
 {
     $encodedString = '';
     if (Charset::isUTF8($string)) {
         $len = mb_strlen($string, Charset::UTF_8);
         for ($i = 0; $i < $len; $i++) {
             $char = mb_substr($string, $i, 1, Charset::UTF_8);
             $encodedString .= '&#' . self::ord($char) . ';';
         }
     } else {
         $len = strlen($string);
         for ($i = 0; $i < $len; $i++) {
             $char = substr($string, $i, 1);
             $encodedString .= '&#' . self::ord($char) . ';';
         }
     }
     return $encodedString;
 }
Ejemplo n.º 2
0
 public function testIsNotASCII()
 {
     $this->assertFalse(Charset::isASCII('ö'));
 }