For .. in over string characters does not respect ZEROBASEDSTRINGS.
...Seemingly running its internal counter from 1 to length(s)
. (ADVERTISEMENT: using start and end pointers would be inherently immune.)
This code:
{$mode objfpc} {$h+} {$coperators+} {$zerobasedstrings+}
uses
SysUtils;
var
s: string;
c: char;
begin
s := '';
for c in string('share this to instantly die') do
if (c >= #32) and (c <= #127) then s += c else s += '#' + IntToStr(ord(c));
writeln(s);
end.
either throws a range error or prints:
hare this to instantly die#0