Skip to content

Commit

Permalink
[PHP 8.4] Add mb_* functions (php#3922)
Browse files Browse the repository at this point in the history
Co-authored-by: Gina Peter Banyard <girgias@php.net>
Co-authored-by: tekimen <youkidearitai@gmail.com>
  • Loading branch information
3 people authored Oct 24, 2024
1 parent 0185cc3 commit 27ae0a4
Show file tree
Hide file tree
Showing 10 changed files with 565 additions and 219 deletions.
44 changes: 44 additions & 0 deletions language-snippets.ent
Original file line number Diff line number Diff line change
Expand Up @@ -3774,6 +3774,50 @@ local: {
'>

<!-- strings snippets -->
<!ENTITY strings.stripped.characters '
<itemizedlist xmlns="http://docbook.org/ns/docbook">
<listitem>
<simpara>
<literal>" "</literal> (<acronym>ASCII</acronym> 32 (0x20)), an ordinary space.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>"\t"</literal> (<acronym>ASCII</acronym> 9 (0x09)), a tab.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>"\n"</literal> (<acronym>ASCII</acronym> 10 (0x0A)), a new line (line feed).
</simpara>
</listitem>
<listitem>
<simpara>
<literal>"\r"</literal> (<acronym>ASCII</acronym> 13 (0x0D)), a carriage return.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>"\0"</literal> (<acronym>ASCII</acronym> 0 (0x00)), the NUL-byte.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>"\v"</literal> (<acronym>ASCII</acronym> 11 (0x0B)), a vertical tab.
</simpara>
</listitem>
</itemizedlist>
'>

<!ENTITY strings.parameter.characters.optional '
<simpara xmlns="http://docbook.org/ns/docbook">
Optionally, the stripped characters can also be specified using
the <parameter>characters</parameter> parameter.
Simply list all characters that need to be stripped.
With <literal>..</literal> it is possible to specify an incrementing range of characters.
</simpara>
'>

<!ENTITY strings.parameter.encoding '
<para xmlns="http://docbook.org/ns/docbook">
An optional argument defining the encoding used when converting characters.
Expand Down
81 changes: 81 additions & 0 deletions reference/mbstring/functions/mb-lcfirst.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="function.mb-lcfirst" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>mb_lcfirst</refname>
<refpurpose>Make a string's first character lowercase</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>mb_lcfirst</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<simpara>
Performs a multi-byte safe <function>lcfirst</function> operation,
and returns a string with the first character of
<parameter>string</parameter> lowercased if that character is
an ASCII character in the range <literal>"A"</literal> (0x41) to
<literal>"Z"</literal> (0x5a).
</simpara>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<simpara>
The input string.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>encoding</parameter></term>
<listitem>
<simpara>
The string encoding.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<simpara>
Returns the resulting string.
</simpara>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><function>mb_ucfirst</function></member>
<member><function>lcfirst</function></member>
</simplelist>
</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
-->
92 changes: 92 additions & 0 deletions reference/mbstring/functions/mb-ltrim.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="function.mb-ltrim" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>mb_ltrim</refname>
<refpurpose>Strip whitespace (or other characters) from the beginning of a string</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>mb_ltrim</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>characters</parameter><initializer>&null;</initializer></methodparam>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<simpara>
Performs a multi-byte safe <function>ltrim</function> operation.
Strip whitespace (or other characters) from the beginning of a string.
</simpara>
<simpara>
Without the second parameter,
<function>mb_ltrim</function> will strip these characters:
</simpara>
&strings.stripped.characters;
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<simpara>
The input string.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>characters</parameter></term>
<listitem>
&strings.parameter.characters.optional;
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>encoding</parameter></term>
<listitem>
<simpara>
The string encoding.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<simpara>
This function returns a string with whitespace stripped from the
beginning of <parameter>string</parameter>.
</simpara>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><function>mb_trim</function></member>
<member><function>mb_rtrim</function></member>
<member><function>ltrim</function></member>
</simplelist>
</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
-->
92 changes: 92 additions & 0 deletions reference/mbstring/functions/mb-rtrim.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="function.mb-rtrim" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>mb_rtrim</refname>
<refpurpose>Strip whitespace (or other characters) from the end of a string</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>mb_rtrim</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>characters</parameter><initializer>&null;</initializer></methodparam>
<methodparam choice="opt"><type>string</type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<simpara>
Performs a multi-byte safe <function>rtrim</function> operation,
and returns a string with whitespace (or other characters) stripped from the
end of <parameter>string</parameter>.
</simpara>
<simpara>
Without the second parameter,
<function>rtrim</function> will strip these characters:
</simpara>
&strings.stripped.characters;
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<simpara>
The input string.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>characters</parameter></term>
<listitem>
&strings.parameter.characters.optional;
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>encoding</parameter></term>
<listitem>
<simpara>
The string encoding.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<simpara>
Returns the modified string.
</simpara>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><function>mb_trim</function></member>
<member><function>mb_ltrim</function></member>
<member><function>rtrim</function></member>
</simplelist>
</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
-->
Loading

0 comments on commit 27ae0a4

Please sign in to comment.