> > Multibyte encoding may contains '?' as a trailing char.
> > So ``full_path.encode('mbcs', 'replace').replace('?', '_')`` may break
> > multibyte char.
>
> Really? Even SJIS avoids that one, and it's pretty good at breaking naïve
> programs. I get the reasoning now though.
I've checked SJIS and BIG5 a little while ago, and find '?' (0x3f) is not in trailing char.
So replace('?', '_') may be safe.
But I doesn't like depending character mapping.
I think encoded string is magic bytes and modifying it is dangerous.
> > Multibyte encoding may contains '?' as a trailing char. path.encode( 'mbcs', 'replace' ).replace( '?', '_')`` may break
> > So ``full_
> > multibyte char.
>
> Really? Even SJIS avoids that one, and it's pretty good at breaking naïve
> programs. I get the reasoning now though.
I've checked SJIS and BIG5 a little while ago, and find '?' (0x3f) is not in trailing char.
So replace('?', '_') may be safe.
But I doesn't like depending character mapping.
I think encoded string is magic bytes and modifying it is dangerous.