[fpc-pascal] TStringHelper and Utf8String
Thomas Kurz
fpc.2021 at t-net.ruhr
Thu Aug 27 23:14:07 CEST 2026
Hello,
I love the helper functions from SysUtils' `TStringHelper`. Unfortunately, they're only available for `String`, but not for other types like `Utf8String` or `RawByteString`.
Is it safe to cast to `String()` and then invoking the helper, e.g. `String(AUtf8String).IndexOf('foo')`? Or does this casting involve a codepage conversion?
I've tried with my FPC installation:
program Project1;
uses sysutils;
var S: Utf8string;
begin
S := 'äfoo';
writeln (String(S).IndexOf('f')); // prints "2", as expected
end.
But can I rely on it?
Are there any plans of making string helpers available for `Utf8String` and `RawByteString`?
Kind regards,
Thomas
More information about the fpc-pascal
mailing list