I need to remove eventual trailing directory separators (slash character '/', maybe several of them together) from a file path. The Perl string with the file path was originally read from a UTF-8 text file and is internally flagged as UTF-8. This is only an example, I am doing more string operations like that.
I would have thought that doing a substr() on a UTF-8 string would respect the UTF-8 flag. However, the string I get back is always flagged as "native/raw bytes". Well, at least with the test strings I am using, which admittedly are all ASCII at the moment. In any case, changing the UTF-8/native flag creates problems in my code later on the line.
Is this substr() behaviour expected? I have tested it with the Perl version v5.26.1 that comes with Ubuntu 18.04.4.