note 130283 added to function.rawurlencode
| From: | ph_corp@yahoo.fr | Date: | Wed, 07 May 2025 09:35:14 +0000 |
| Subject: | note 130283 added to function.rawurlencode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-222128@lists.php.net to get a copy of this message | ||
I had an issue with multibyte character encoding, my implementation below:
```php
function mb_rawurlencode(string $url): string
{
return implode('', array_map(
static fn (string $char): string => preg_match('/[\w-]/', $char)
? $char
: sprintf('%%%s', wordwrap(strtoupper(bin2hex($char)), 2, '%',
true)),
mb_str_split($url)
));
}
```
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 193.58.247.50)
----
Manual Page -- https://php.net/manual/en/function.rawurlencode.php
Edit -- https://main.php.net/note/edit/130283
Del: integrated -- https://main.php.net/note/delete/130283/integrated
Del: useless -- https://main.php.net/note/delete/130283/useless
Del: bad code -- https://main.php.net/note/delete/130283/bad+code
Del: spam -- https://main.php.net/note/delete/130283/spam
Del: non-english -- https://main.php.net/note/delete/130283/non-english
Del: in docs -- https://main.php.net/note/delete/130283/in+docs
Del: other reasons-- https://main.php.net/note/delete/130283
Reject -- https://main.php.net/note/reject/130283
Search -- https://main.php.net/manage/user-notes.php