Commit eb10503
authored
Add examples for mb_scrub() (#5811)
* Add examples for mb_scrub()
The page had no example, which made it hard to see that the replacement
happens in the string itself: terminals, browsers and fonts render an
ill-formed byte sequence with a replacement character of their own, so
visual output alone is misleading. Both examples use bin2hex() or
var_dump() so the reader sees the bytes rather than the rendering.
The first example also shows that the result depends on the substitute
character: mbstring.substitute_character defaults to "?" (0x3F), so the
scrubbed string is 41 3f 42, and 41 ef bf bd 42 only after calling
mb_substitute_character(0xFFFD).
The second example shows the practical use: a PCRE pattern with the u
modifier fails on the raw input and succeeds once it has been scrubbed.
A see also section is added, since the page had none and the substitute
character is a prerequisite for reading the first example.
Outputs verified on PHP 8.1, 8.4 and 8.5.
Fixes: #5562
* Unwrap examples and see also list from para1 parent d3a03f8 commit eb10503
1 file changed
Lines changed: 78 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
74 | 152 | | |
75 | 153 | | |
76 | 154 | | |
| |||
0 commit comments