10000 [String] Document the bytesAt() method · symfony/symfony-docs@980a716 · GitHub
[go: up one dir, main page]

Skip to content

Commit 980a716

Browse files
committed
[String] Document the bytesAt() method
1 parent 5cef387 commit 980a716

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
@@ -145,6 +145,16 @@ Each string object can be transformed into the other two types of objects::
145145
If the conversion is not possible for any reason, you'll get an
146146
:class:`Symfony\\Component\\String\\Exception\\InvalidArgumentException`.
147147

148+
There is also a method to get the bytes stored at some position::
149+
150+
// ('नमस्ते' bytes = [224, 164, 168, 224, 164, 174, 224, 164, 184,
151+
// 224, 165, 141, 224, 164, 164, 224, 165, 135])
152+
b('नमस्ते')->bytesAt(0); // [224]
153+
u('नमस्ते')->bytesAt(0); // [224, 164, 168]
154+
155+
b('नमस्ते')->bytesAt(1); // [168]
156+
u('नमस्ते')->bytesAt(1); // [224, 164, 184, 224, 165, 141]
157+
148158
Methods Related to Length and White Spaces
149159
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
150160

@@ -367,12 +377,6 @@ These methods are only available for ``ByteString`` objects::
367377
b('Lorem Ipsum')->isUtf8(); // true
368378
b("\xc3\x28")->isUtf8(); // false
369379

370-
// returns the value of the byte stored at the given position
371-
// ('नमस्ते' bytes = [224, 164, 168, 224, 164, 174, 224, 164, 184,
372-
// 224, 165, 141, 224, 164, 164, 224, 165, 135])
373-
b('नमस्ते')->byteCode(0); // 224
374-
b('नमस्ते')->byteCode(17); // 135
375-
376380
Methods Added by CodePointString and UnicodeString
377381
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
378382

0 commit comments

Comments
 (0)
0