# RFC [Discussion]: mb_str_pad

- Thread: https://externals.io/message/120369
- Original archive: https://news-web.php.net/php.internals/120369
- Started by Niels Dossche on 2023-05-20T12:53:20+00:00
- Messages: 8
- RFC: mb_str_pad (Implemented (PHP 8.3)) — https://externals.io/rfc/mb_str_pad.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #120369 — Niels Dossche — 2023-05-20T12:53:20+00:00

URL: https://externals.io/message/120369#120369

Hello internals

I'm opening the discussion for my RFC to implement mb_str_pad.

RFC: https://wiki.php.net/rfc/mb_str_pad
Implementation pull request: https://github.com/php/php-src/pull/11284

Kind regards
Niels

---

## #120370 — Rowan Tommins — 2023-05-20T15:13:00+00:00

URL: https://externals.io/message/120369#120370 · In reply to: #120369

>RFC: https://wiki.php.net/rfc/mb_str_pad

Hi Niels,

This seems like a reasonable addition. My only hesitation is that it will share with other mbstring functions the slightly dubious definition of "character" as "code point", rather than "grapheme", when dealing with Unicode strings.

This is most easily demonstrated using combining diacritics, e.g. "Franc\u{0327}ais" is 9 code points long, but visually identical to the 8 code point "Fran\u{00E7}ais" used in your examples. Unicode defines "graphemes" or "grapheme clusters" to better match the common intuition of what a "character" means.

Perhaps we should instead, or also, add a "grapheme_strpad" function to ext/intl?

Regards,

-- 
Rowan Tommins
[IMSoP]

---

## #120371 — Niels Dossche — 2023-05-20T15:56:21+00:00

URL: https://externals.io/message/120369#120371 · In reply to: #120370

Hi Rowan


> 
> > […]
> 
> Hi Niels,
> 
> This seems like a reasonable addition. My only hesitation is that it will share with other mbstring functions the slightly dubious definition of "character" as "code point", rather than "grapheme", when dealing with Unicode strings.
> 
> This is most easily demonstrated using combining diacritics, e.g. "Franc\u{0327}ais" is 9 code points long, but visually identical to the 8 code point "Fran\u{00E7}ais" used in your examples. Unicode defines "graphemes" or "grapheme clusters" to better match the common intuition of what a "character" means.
> 

Thanks for your insight.

This is a good point. I've added a clarification in the RFC text to make clear the definition of character is code point in this case, consistent with mbstring.

> Perhaps we should instead, or also, add a "grapheme_strpad" function to ext/intl?
> 
> Regards,
> 

I've added this suggestion to the future scope section.

Kind regards
Niels

---

## #120378 — Jorg Sowa — 2023-05-21T22:08:10+00:00

URL: https://externals.io/message/120369#120378 · In reply to: #120369

Hello,
As this is a new function do you consider any namespace for it? Based on
passed RFC[1] allowing for namespaces in bundled extensions it would be
nice to introduce new functions with namespace. Maybe the namespace could
be voted in the RFC separately?

Kind regards,
Jorg

[1] https://wiki.php.net/rfc/namespaces_in_bundled_extensions

---

## #120379 — tim@bastelstu.be — 2023-05-22T07:23:28+00:00

URL: https://externals.io/message/120369#120379 · In reply to: #120378

Hi


> As this is a new function do you consider any namespace for it? Based on
> passed RFC[1] allowing for namespaces in bundled extensions it would be
> nice to introduce new functions with namespace. Maybe the namespace could
> be voted in the RFC separately?
> […]
> [1] https://wiki.php.net/rfc/namespaces_in_bundled_extensions

As per that RFC:

>  When adding new symbols to existing extensions, it is more important to be consistent with existing symbols than to follow the namespacing guidelines. 

Best regards
Tim Düsterhus

---

## #120387 — Niels Dossche — 2023-05-22T14:50:32+00:00

URL: https://externals.io/message/120369#120387 · In reply to: #120378

Hi


> Hello,
> As this is a new function do you consider any namespace for it? Based on
> passed RFC[1] allowing for namespaces in bundled extensions it would be
> nice to introduce new functions with namespace. Maybe the namespace could
> be voted in the RFC separately?

Tim already answered the first question, and I agree with his answer (thanks for looking it up Tim).
Introducing a single function to a new namespace doesn't make much sense to me.
If we'd want to alias the mbstring functions in a namespace then this should go into a separate RFC in my opinion.

> 
> Kind regards,
> Jorg
> 
> [1] https://wiki.php.net/rfc/namespaces_in_bundled_extensions
> 
Kind regards
Niels

---

## #120388 — Jorg Sowa — 2023-05-22T16:01:19+00:00

URL: https://externals.io/message/120369#120388 · In reply to: #120387

It's a reasonable approach. Thanks for clearing it up.

Kind regards,
Jorg

---

## #120520 — Niels Dossche — 2023-06-04T11:58:23+00:00

URL: https://externals.io/message/120369#120520 · In reply to: #120369

Hi internals

I haven't seen more discussion for some time now.
I plan on starting the vote tomorrow evening 20:00 GMT+2, and to end it on June 19 20:00 GMT+2.
Any final comments should be raised now.

Kind regards
Niels
