mirror of
https://github.com/php/doc-ja.git
synced 2026-03-24 07:02:08 +01:00
- reference/mbstring/functions/mb-decode-numericentity.xml 1. php/doc-en@4e69a9f2b1 - reference/imap/functions/imap-headerinfo.xml 1. php/doc-en@4e69a9f2b1 - reference/ssh2/functions/ssh2-auth-pubkey-file.xml 1. php/doc-en@74ef2355c5 - reference/ssh2/functions/ssh2-connect.xml 1. php/doc-en@74ef2355c5 - reference/stream/functions/stream-filter-append.xml 1. php/doc-en@a684294e0b - reference/stream/functions/stream-filter-prepend.xml 1. php/doc-en@a684294e0b - reference/filesystem/functions/fgetcsv.xml 1. php/doc-en@e1fd0bef1d 2. php/doc-en@0a3648a718 3. `&warning.csv.escape-parameter;` の重複を削除(既訳のバグ修正) - reference/spl/splfileobject/fgetcsv.xml 1. php/doc-en@e1fd0bef1d 2. php/doc-en@3a89b55d11 3. php/doc-en@0a3648a718 - language/predefined/attributes/nodiscard.xml 1. php/doc-en@30bda33771 - reference/pdo_sqlite/pdo/sqlite/createfunction.xml 1. php/doc-en@28930349ca - reference/math/functions/fmod.xml 1. php/doc-en@54a788ca59 - reference/simplexml/simplexmlelement/addChild.xml 1. php/doc-en@dca2a8354f - reference/json/functions/json-last-error.xml 1. php/doc-en@058ea1e842 - features/commandline.xml 1. php/doc-en@96b10a9885 - appendices/migration85/incompatible.xml 1. php/doc-en@048982b729 2. php/doc-en@f81bbcf9d3 - reference/random/random/randomizer/getfloat.xml 1. php/doc-en@1ada637cc8 2. php/doc-en@423a1da63f - reference/mysqli/mysqli/multi-query.xml 1. php/doc-en@1beae37b69 - reference/image/functions/getimagesize.xml 1. php/doc-en@6bb90d24b2 - reference/curl/functions/curl-close.xml 1. php/doc-en@86c8ebd19e - reference/curl/functions/curl-share-close.xml 1. php/doc-en@29c3d13980 - reference/yaml/functions/yaml-parse-file.xml 1. php/doc-en@132d2a8d63 - reference/mysqli/mysqli/options.xml 1. php/doc-en@e309a62b16 2. MYSQLI_SERVER_PUBLIC_KEY の古い「PHP 5.5.0 以降」テキストを削除(既訳のバグ修正) - appendices/transports.xml 1. php/doc-en@ae90ecc932 - reference/soap/soapserver/addfunction.xml 1. php/doc-en@577239f64b - reference/var/functions/settype.xml 1. php/doc-en@8d49e302b4 - features/http-auth.xml 1. php/doc-en@cd4180557a
219 lines
6.1 KiB
XML
219 lines
6.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 4e69a9f2b14deefca0befec576335e33152448f3 Maintainer: takagi Status: ready -->
|
|
<!-- CREDITS: hirokawa,mumumu -->
|
|
<refentry xml:id="function.mb-decode-numericentity" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>mb_decode_numericentity</refname>
|
|
<refpurpose>HTML 数値エンティティを文字にデコードする</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>mb_decode_numericentity</methodname>
|
|
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>map</parameter></methodparam>
|
|
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
文字列 <parameter>string</parameter>
|
|
において指定した文字領域にある数値エンティティを変換し、
|
|
変換後の文字列を返します。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>string</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
デコードする文字列。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>map</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<parameter>map</parameter>
|
|
は変換するコード領域を指定する配列です。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>encoding</parameter></term>
|
|
<listitem>
|
|
&mbstring.encoding.parameter;
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
変換された文字列を返します。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<simpara>
|
|
<parameter>map</parameter> が整数のリストでない場合、
|
|
<exceptionname>ValueError</exceptionname> がスローされます。
|
|
</simpara>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>8.4.0</entry>
|
|
<entry>
|
|
<parameter>map</parameter> が整数のリストでない場合、
|
|
<function>mb_decode_numericentity</function> は
|
|
<exceptionname>ValueError</exceptionname> をスローするようになりました。
|
|
</entry>
|
|
</row>
|
|
&mbstring.changelog.encoding-nullable;
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><parameter>map</parameter> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$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'をとり、
|
|
// 数値エンティティに値を変換します。
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
|
|
<para>
|
|
<example>
|
|
<title><parameter>map</parameter> を使って JavaScript の文字列をエスケープする例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
function escape_javascript_string($str) {
|
|
$map = [
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,0,0, // 49
|
|
0,0,0,0,0,0,0,0,1,1,
|
|
1,1,1,1,1,0,0,0,0,0,
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
0,1,1,1,1,1,1,0,0,0, // 99
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
0,0,0,0,0,0,0,0,0,0,
|
|
0,0,0,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,1,1, // 149
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,1,1, // 199
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,1,1,
|
|
1,1,1,1,1,1,1,1,1,1, // 249
|
|
1,1,1,1,1,1,1, // 255
|
|
];
|
|
// 文字エンコーディングは UTF-8
|
|
$mblen = mb_strlen($str, 'UTF-8');
|
|
$utf32 = bin2hex(mb_convert_encoding($str, 'UTF-32', 'UTF-8'));
|
|
for ($i=0, $encoded=''; $i < $mblen; $i++) {
|
|
$u = substr($utf32, $i*8, 8);
|
|
$v = base_convert($u, 16, 10);
|
|
if ($v < 256 && $map[$v]) {
|
|
$encoded .= '\\x'.substr($u, 6,2);
|
|
} else if ($v == 2028) {
|
|
$encoded .= '\\u2028';
|
|
} else if ($v == 2029) {
|
|
$encoded .= '\\u2029';
|
|
} else {
|
|
$encoded .= mb_convert_encoding(hex2bin($u), 'UTF-8', 'UTF-32');
|
|
}
|
|
}
|
|
return $encoded;
|
|
}
|
|
|
|
// テストデータ
|
|
$convmap = [ 0x0, 0xffff, 0, 0xffff ];
|
|
$msg = '';
|
|
for ($i=0; $i < 1000; $i++) {
|
|
// chr() では 128 より大きい UTF-8 データを正しく生成できないので、mb_decode_numericentity() を使います
|
|
$msg .= mb_decode_numericentity('&#'.$i.';', $convmap, 'UTF-8');
|
|
}
|
|
|
|
// var_dump($msg);
|
|
var_dump(escape_javascript_string($msg));
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>mb_encode_numericentity</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|