<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 15/01/2024 15:23, 刘希晨 wrote:<br>
</div>
<blockquote type="cite" cite="mid:CABUmArSEb7qVjX8sQ6cnETBL6qZuxYeWH1unoYOuXG3N2frkPg@mail.gmail.com">
<div>For example, in <a href="https://urldefense.com/v3/__https://www.postgresql.org/docs/current/protocol-message-formats.html__;!!ACWV5N9M2RV99hQ!MyEp6roAVJiCW7ICOb0qsj7sTbl0-6FMpSP_cUorkgFXlpYaIVusJQFoY7eOtiEupFUi3lUU5xivRt9F_QCYn96J52eW$" moz-do-not-send="true">https://www.postgresql.org/docs/current/protocol-message-formats.html</a>,
the postgresql startup message contains a length prefix
indicates the total length, while within the message body,
multiple string were represented as key-value pair, so we need
to call MemorySegment.getString() multiple times to
retrieve them, and we must care about the offset value here.</div>
<div><br>
</div>
<div>Thus I think it's quite useful to have a getStringBytes() API
in memorySegment, it would be needed and constantly used.</div>
</blockquote>
<p>Thanks for the pointer. It is indeed a case of "back to back"
strings.</p>
<p>One possible workaround, with current API, is to simply get the
string first, then get the string bytes (and that would be your
"next offset").</p>
<p>Another thing you probably need in this mode is some kind of
start offset as well (otherwise you need to slice). So perhaps the
getStringBytes() could be a lower-level method which takes a start
offset.</p>
<p>Maurizio<br>
</p>
</body>
</html>