Difference in encoding semantics of URI returned by File.toURI and Path.toUri representing the same file

Daniel Fuchs daniel.fuchs at oracle.com
Wed Jan 13 19:11:16 UTC 2021


Hi Sebastian,

On 13/01/2021 18:45, Sebastian Stenzel wrote:
>> [...]
>> It's not clear to me whether NFC should be applied - or what would be
>> the consequences of applying NFC there (or not).
> 
> While I can't answer this question, it may be worth mentioning RFC 3987 which might not be directly applicable but also deals with the representation of non-ASCII data in URIs.
> 
> In section 3 it explicitly asks for NFC-normalization_before_  applying percent-encoding. I can't tell what's the rationale behind this decision but possibly the behaviour of URI.toASCIIString() is in the spirit of these rules.

Yes - I believe URI does the right thing.

I was however musing about changing the behavior of Path.toURI() in
that respect, and whether using NFC or not in Path.toURI() could
potentially prevent Path.of(URI) to find back the same file on the
file system.

best regards,

-- daniel


More information about the core-libs-dev mailing list