Question

I'm a little confused by this. I notice that some web APIs use the | character (eg the mediawiki api - see "action=opensearch", the parameter "namespace" says you separate items with |).

However I also see that it is strictly not allowed according to the w3 URL spec and this SO question.

So have I misunderstood the examples (such as mediawiki) that I've seen? Do the browsers URL encode it for me behind the scenes? Does this work with some web browsers and servers but will break in others?

As I'm creating a web API schema that code will be accessing not going through a browser I'd like to understand this properly. It would be nice to clear to use | for some terms, but I'll use the URL encode trick if it seems too dodgy.

Was it helpful?

Solution

No, the | is not a valid character in URIs and needs to be encoded using the percent-encoding.

But apart from this, browsers might display the percent-encoded octet %7C as | just like percent-encoded UTF-8 byte sequences are displayed as the characters they represent.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top