From 980a7166f9ffc48901ffae75bcaafcf28dd50806 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 7 Apr 2020 11:47:17 +0200 Subject: [PATCH] [String] Document the bytesAt() method --- components/string.rst | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/components/string.rst b/components/string.rst index 3db3a5df851..1a06c5ad69f 100644 --- a/components/string.rst +++ b/components/string.rst @@ -145,6 +145,16 @@ Each string object can be transformed into the other two types of objects:: If the conversion is not possible for any reason, you'll get an :class:`Symfony\\Component\\String\\Exception\\InvalidArgumentException`. +There is also a method to get the bytes stored at some position:: + + // ('नमस्ते' bytes = [224, 164, 168, 224, 164, 174, 224, 164, 184, + // 224, 165, 141, 224, 164, 164, 224, 165, 135]) + b('नमस्ते')->bytesAt(0); // [224] + u('नमस्ते')->bytesAt(0); // [224, 164, 168] + + b('नमस्ते')->bytesAt(1); // [168] + u('नमस्ते')->bytesAt(1); // [224, 164, 184, 224, 165, 141] + Methods Related to Length and White Spaces ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -367,12 +377,6 @@ These methods are only available for ``ByteString`` objects:: b('Lorem Ipsum')->isUtf8(); // true b("\xc3\x28")->isUtf8(); // false - // returns the value of the byte stored at the given position - // ('नमस्ते' bytes = [224, 164, 168, 224, 164, 174, 224, 164, 184, - // 224, 165, 141, 224, 164, 164, 224, 165, 135]) - b('नमस्ते')->byteCode(0); // 224 - b('नमस्ते')->byteCode(17); // 135 - Methods Added by CodePointString and UnicodeString ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~