<div dir="auto"><div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Bart via fpc-devel <<a href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>> schrieb am So., 6. Apr. 2025, 23:19:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Is this a known issue?<br>
===<br>
program z;<br>
<br>
{$longstrings on}<br>
{$zerobasedstrings on}<br>
<br>
var<br>
S, T: string;<br>
begin<br>
S := 'ABC';<br>
write('S[0] = "',S[0],'"');<br>
if (S[0] <> 'A') then writeln(', FAIL: expected: A') else writeln(' [Ok]');<br>
write('S[1] = "',S[1],'"');<br>
if (S[1] <> 'B') then writeln(', FAIL: expected: A') else writeln(' [Ok]');<br>
write('S[2] = "',S[2],'"');<br>
if (S[2] <> 'C') then writeln(', FAIL: expected: A') else writeln(' [Ok]');<br>
T := Copy(S,0,1);<br>
write('Copy(S,0,1) = "',T,'"');<br>
if (T <> 'A') then writeln(', FAIL: expected: A') else writeln(' [Ok]');<br>
T := Copy(S,1,1);<br>
write('Copy(S,1,1) = "',T,'"');<br>
if (T <> 'B') then writeln(', FAIL: expected: B') else writeln(' [Ok]');<br>
end.<br>
===<br>
<br>
Outputs:<br>
S[0] = "A" [Ok]<br>
S[1] = "B" [Ok]<br>
S[2] = "C" [Ok]<br>
Copy(S,0,1) = "A" [Ok]<br>
Copy(S,1,1) = "A", FAIL: expected: B<br>
<br>
<br>
(I played a little with this because Copy() accepts Index < 1 for<br>
"normal" AnsiStrings, and in Lazarus Utf8Copy() does not, so I wanted<br>
to see how his behaved with zerobasedstrings on.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Please report a bug. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
B.t.w. Is there an associate short option for this, as currently you<br>
cannot check {$IFOPT zerobasedstrings+} nor any other longoptions<br>
IIRC.)<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">No there's not.</div><div dir="auto"><br></div><div dir="auto">Also it would be best to simply document as UTF8Copy working 1-based because you can't detect from the callee-side whether it had been enabled on the caller-side (especially if they're from different units). </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>