Forum und email

mb_encode_numericentity

(PHP 4 >= 4.0.6, PHP 5)

mb_encode_numericentity — 文字を HTML 数値エンティティにエンコードする

説明

string mb_encode_numericentity ( string $str , array $convmap [, string $encoding ] )

mb_encode_numericentity() は、 str の中で指定した文字コードを HTML 数値エンティティから文字コードに変換します。 この関数は変換後の文字列を返します。

convmap は、変換するコード領域を指定する配列です。

encoding は文字エンコーディングです。

Example#1 convmap の例

$convmap = array (
 int start_code1, int end_code1, int offset1, int mask1,
 int start_code2, int end_code2, int offset2, int mask2,
 ........
 int start_codeN, int end_codeN, int offsetN, int maskN );
// start_codeN および end_codeN に Unicode 値を指定
// 値に offsetN を追加、マスク maskN を指定してビット毎の'AND'をとり、
// 数値エンティティに値を変換します。

Example#2 mb_encode_numericentity() の例

<?php
/* ISO-8859-1 の左面をHTML数値エンティティに変換 */
$convmap = array(0x800xff00xff);
$str mb_encode_numericentity($str$convmap"ISO-8859-1");

/* ブロック 95-104 にある SJIS-win コードのユーザ定義領域を
   数値エンティティに変換 */
$convmap = array(
       
0xe0000xe03e0x10400xffff,
       
0xe03f0xe0bb0x10410xffff,
       
0xe0bc0xe0fa0x10840xffff,
       
0xe0fb0xe1770x10850xffff,
       
0xe1780xe1b60x10c80xffff,
       
0xe1b70xe2330x10c90xffff,
       
0xe2340xe2720x110c0xffff,
       
0xe2730xe2ef0x110d0xffff,
       
0xe2f00xe32e0x11500xffff,
       
0xe32f0xe3ab0x11510xffff );
$str mb_encode_numericentity($str$convmap"sjis-win");
?>

mb_decode_numericentity() も参照ください。