Skip to content

Commit 2db1e48

Browse files
committed
Merge branch '5.0'
* 5.0: [String] Document the bytesAt() method
2 parents 0a83616 + e9967f3 commit 2db1e48

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

components/string.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@ Each string object can be transformed into the other two types of objects::
155155
If the conversion is not possible for any reason, you'll get an
156156
:class:`Symfony\\Component\\String\\Exception\\InvalidArgumentException`.
157157

158+
There is also a method to get the bytes stored at some position::
159+
160+
// ('नमस्ते' bytes = [224, 164, 168, 224, 164, 174, 224, 164, 184,
161+
// 224, 165, 141, 224, 164, 164, 224, 165, 135])
162+
b('नमस्ते')->bytesAt(0); // [224]
163+
u('नमस्ते')->bytesAt(0); // [224, 164, 168]
164+
165+
b('नमस्ते')->bytesAt(1); // [168]
166+
u('नमस्ते')->bytesAt(1); // [224, 164, 184, 224, 165, 141]
167+
158168
Methods Related to Length and White Spaces
159169
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160170

@@ -405,12 +415,6 @@ These methods are only available for ``ByteString`` objects::
405415
b('Lorem Ipsum')->isUtf8(); // true
406416
b("\xc3\x28")->isUtf8(); // false
407417

408-
// returns the value of the byte stored at the given position
409-
// ('नमस्ते' bytes = [224, 164, 168, 224, 164, 174, 224, 164, 184,
410-
// 224, 165, 141, 224, 164, 164, 224, 165, 135])
411-
b('नमस्ते')->byteCode(0); // 224
412-
b('नमस्ते')->byteCode(17); // 135
413-
414418
Methods Added by CodePointString and UnicodeString
415419
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
416420

0 commit comments

Comments
 (0)