From b17c366928be4729044615ac87ec13bce31db922 Mon Sep 17 00:00:00 2001 From: Yuya Hamada Date: Thu, 7 Sep 2023 23:54:41 +0900 Subject: [PATCH 1/8] Copy and modify mb_str_pad from str_pad --- appendices/aliases.xml | 5 + reference/mbstring/functions/mb-str-pad.xml | 135 ++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 reference/mbstring/functions/mb-str-pad.xml diff --git a/appendices/aliases.xml b/appendices/aliases.xml index 4a1b4e4da0f6..e82666080ae2 100644 --- a/appendices/aliases.xml +++ b/appendices/aliases.xml @@ -226,6 +226,11 @@ mb_strlen Multi-bytes Strings + + mbstrpad + mb_str_pad + Multi-bytes Strings + mbstrpos mb_strpos diff --git a/reference/mbstring/functions/mb-str-pad.xml b/reference/mbstring/functions/mb-str-pad.xml new file mode 100644 index 000000000000..c10c3d2603fd --- /dev/null +++ b/reference/mbstring/functions/mb-str-pad.xml @@ -0,0 +1,135 @@ + + + + + mb_str_pad + Pad a string to a certain length with another string to multibyte version + + + + &reftitle.description; + + stringmb_str_pad + stringstring + intlength + stringpad_string" " + intpad_typeSTR_PAD_RIGHT + stringencodingnull + + + This function returns the string string + padded on the left, the right, or both sides to the specified + padding length. If the optional argument + pad_string is not supplied, the + string is padded with spaces, otherwise it + is padded with characters from pad_string + up to the limit. + + + + + &reftitle.parameters; + + + + string + + + The input string. + + + + + length + + + If the value of length is negative, + less than, or equal to the length of the input string, no padding + takes place, and string will be returned. + + + + + pad_string + + + + The pad_string may be truncated if the + required number of padding characters can't be evenly divided by the + pad_string's length. + + + + + + pad_type + + + Optional argument pad_type can be + STR_PAD_RIGHT, STR_PAD_LEFT, + or STR_PAD_BOTH. If + pad_type is not specified it is assumed to be + STR_PAD_RIGHT. + + + + + encoding + + + Optional argument encoding must be a valid and supported character encoding, if provided. Otherwise it will output a value error just like the other mbstring functions do with an invalid encoding. + + + + + + + + + &reftitle.returnvalues; + + Returns the padded string. + + + + + + &reftitle.examples; + + + <function>mb_str_pad</function> example + + +]]> + + + + + + + + From bdb3efeeec2031f52d92ee44373b363c859bda2a Mon Sep 17 00:00:00 2001 From: Yuya Hamada Date: Thu, 7 Sep 2023 23:58:06 +0900 Subject: [PATCH 2/8] Add new examples with emoji --- reference/mbstring/functions/mb-str-pad.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reference/mbstring/functions/mb-str-pad.xml b/reference/mbstring/functions/mb-str-pad.xml index c10c3d2603fd..b07660099677 100644 --- a/reference/mbstring/functions/mb-str-pad.xml +++ b/reference/mbstring/functions/mb-str-pad.xml @@ -104,6 +104,8 @@ var_dump(mb_str_pad('▶▶', 6, '❤❓❇', STR_PAD_RIGHT)); // string(18) "▶▶❤❓❇❤" var_dump(mb_str_pad('▶▶', 6, '❤❓❇', STR_PAD_LEFT)); // string(18) "❤❓❇❤▶▶" var_dump(mb_str_pad('▶▶', 6, '❤❓❇', STR_PAD_BOTH)); // string(18) "❤❓▶▶❤❓" + +var_dump(mb_str_pad("🎉", 3, "祝", STR_PAD_LEFT))); // string(10) "祝祝🎉" ?> ]]> From 4946c56e2ca69ce7956a30c91fbf9402e0aa31b5 Mon Sep 17 00:00:00 2001 From: Yuya Hamada Date: Fri, 8 Sep 2023 00:01:45 +0900 Subject: [PATCH 3/8] remove whitespace --- reference/mbstring/functions/mb-str-pad.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/mbstring/functions/mb-str-pad.xml b/reference/mbstring/functions/mb-str-pad.xml index b07660099677..c5dc4c2eb824 100644 --- a/reference/mbstring/functions/mb-str-pad.xml +++ b/reference/mbstring/functions/mb-str-pad.xml @@ -5,7 +5,7 @@ mb_str_pad Pad a string to a certain length with another string to multibyte version - + &reftitle.description; From 2cf72c99ff6581cc8e8e859ee27e3085b1803c43 Mon Sep 17 00:00:00 2001 From: Yuya Hamada Date: Fri, 8 Sep 2023 00:03:55 +0900 Subject: [PATCH 4/8] remove blank line at EOF --- reference/mbstring/functions/mb-str-pad.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/reference/mbstring/functions/mb-str-pad.xml b/reference/mbstring/functions/mb-str-pad.xml index c5dc4c2eb824..0dab47ac34ff 100644 --- a/reference/mbstring/functions/mb-str-pad.xml +++ b/reference/mbstring/functions/mb-str-pad.xml @@ -134,4 +134,3 @@ vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> - From 2c95be9a8745dfc009ed5669237a283d54509f9e Mon Sep 17 00:00:00 2001 From: Yuya Hamada Date: Fri, 8 Sep 2023 19:47:21 +0900 Subject: [PATCH 5/8] Update suggested changes from nielsdos-san. thanks. --- reference/mbstring/functions/mb-str-pad.xml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/reference/mbstring/functions/mb-str-pad.xml b/reference/mbstring/functions/mb-str-pad.xml index 0dab47ac34ff..0fed49f3a93a 100644 --- a/reference/mbstring/functions/mb-str-pad.xml +++ b/reference/mbstring/functions/mb-str-pad.xml @@ -3,7 +3,7 @@ mb_str_pad - Pad a string to a certain length with another string to multibyte version + Pad a multibyte string to a certain length with another multibyte string @@ -14,12 +14,12 @@ intlength stringpad_string" " intpad_typeSTR_PAD_RIGHT - stringencodingnull + stringnullencoding&null; This function returns the string string padded on the left, the right, or both sides to the specified - padding length. If the optional argument + padding length, where the length is measured in Unicode codepoints. If the optional argument pad_string is not supplied, the string is padded with spaces, otherwise it is padded with characters from pad_string @@ -76,9 +76,7 @@ encoding - - Optional argument encoding must be a valid and supported character encoding, if provided. Otherwise it will output a value error just like the other mbstring functions do with an invalid encoding. - + &mbstring.encoding.parameter; From af6cd0c1b8b80ad161ab2f6d308268d7f847a04c Mon Sep 17 00:00:00 2001 From: Yuya Hamada Date: Fri, 8 Sep 2023 19:53:28 +0900 Subject: [PATCH 6/8] Remove aliases. --- appendices/aliases.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/appendices/aliases.xml b/appendices/aliases.xml index e82666080ae2..4a1b4e4da0f6 100644 --- a/appendices/aliases.xml +++ b/appendices/aliases.xml @@ -226,11 +226,6 @@ mb_strlen Multi-bytes Strings - - mbstrpad - mb_str_pad - Multi-bytes Strings - mbstrpos mb_strpos From 29e825b9859a41135fc38a833d6a92a51afb81a3 Mon Sep 17 00:00:00 2001 From: Yuya Hamada Date: Fri, 8 Sep 2023 21:26:02 +0900 Subject: [PATCH 7/8] Fix parameter description --- reference/mbstring/functions/mb-str-pad.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/reference/mbstring/functions/mb-str-pad.xml b/reference/mbstring/functions/mb-str-pad.xml index 0fed49f3a93a..3799da656ffa 100644 --- a/reference/mbstring/functions/mb-str-pad.xml +++ b/reference/mbstring/functions/mb-str-pad.xml @@ -17,7 +17,7 @@ stringnullencoding&null; - This function returns the string string + This function returns the string padded on the left, the right, or both sides to the specified padding length, where the length is measured in Unicode codepoints. If the optional argument pad_string is not supplied, the @@ -67,9 +67,8 @@ Optional argument pad_type can be STR_PAD_RIGHT, STR_PAD_LEFT, - or STR_PAD_BOTH. If - pad_type is not specified it is assumed to be - STR_PAD_RIGHT. + or STR_PAD_BOTH. + By default STR_PAD_RIGHT. From b13ccc07e12c1085bb3dac0b4e774a9306398e41 Mon Sep 17 00:00:00 2001 From: Yuya Hamada Date: Fri, 8 Sep 2023 23:24:24 +0900 Subject: [PATCH 8/8] add version infomation --- reference/mbstring/versions.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/reference/mbstring/versions.xml b/reference/mbstring/versions.xml index a6f8a493c44c..a2d150b58e38 100644 --- a/reference/mbstring/versions.xml +++ b/reference/mbstring/versions.xml @@ -45,6 +45,7 @@ +