mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-24 15:12:23 +01:00
190 lines
5.2 KiB
XML
190 lines
5.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: a60ef65239113c7871643be68ada91081376c936 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto, leonardolara -->
|
|
<refentry xml:id="function.mb-encode-numericentity" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>mb_encode_numericentity</refname>
|
|
<refpurpose>Codificar caractere para referência numérica HTML</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>mb_encode_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>
|
|
<methodparam choice="opt"><type>bool</type><parameter>hex</parameter><initializer>&false;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Converte
|
|
códigos de caractere especificados em <type>string</type> <parameter>string</parameter>
|
|
de códigos de caractere para referência numérica de caractere HTML.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>string</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
A <type>string</type> a ser codificada.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>map</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<parameter>map</parameter> é um array que especifica a área de código para
|
|
converter.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>encoding</parameter></term>
|
|
<listitem>
|
|
&mbstring.encoding.parameter;
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>hex</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Se a referência de entidade retornada deve estar em notação hexadecimal
|
|
(caso contrário, estará em notação decimal).
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
A <type>string</type> convertida.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<simpara>
|
|
Lança uma exceção <exceptionname>ValueError</exceptionname> se
|
|
<parameter>map</parameter> não for uma lista de &integer;s.
|
|
</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>
|
|
<function>mb_encode_numericentity</function> agora lança uma exceção
|
|
<exceptionname>ValueError</exceptionname> se <parameter>map</parameter>
|
|
não for uma lista de &integer;s.
|
|
</entry>
|
|
</row>
|
|
&mbstring.changelog.encoding-nullable;
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemplo de <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 );
|
|
// Especifique o valor Unicode para start_codeN e end_codeN
|
|
// Adicione offsetN ao valor e faça um 'AND' bit a bit com maskN, então
|
|
// converta o valor para referência numérica de string.
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
|
|
<para>
|
|
<example>
|
|
<title>Exemplo de <function>mb_encode_numericentity</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$str = "aAæÆあア𩸽";
|
|
|
|
/* Converte todos os caracteres UTF8 de até 4 bytes para referência numérica de caracteres HTML */
|
|
$convmap = [0, 0x1FFFFF, 0, 0x10FFFF];
|
|
var_dump(mb_encode_numericentity($str, $convmap, "utf8"));
|
|
|
|
/* Converte somente caracteres UTF8 de 2 bytes e de 4 bytes para referência numérica de caracteres HTML */
|
|
$convmap = [
|
|
0x80, 0x7FF, 0, 0x10FFFF,
|
|
0x10000, 0x1FFFFF, 0, 0x10FFFF,
|
|
];
|
|
var_dump(mb_encode_numericentity($str, $convmap, "utf8"));
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
string(46) "aAæÆあア鸽"
|
|
string(28) "aAæÆあア鸽"
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>mb_decode_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
|
|
-->
|