Re: [whatwg/url] Need an "unreserved" character set (and better define how to percent-encode arbitrary strings) (#369)

Python does not match any RFC - it encodes `~`, and doesn't encode `/`:
```python
quote('-._~') # -._%7E
quote('/') # /
```
I want to make a merge request to Python after this spec decides on what to do - but no idea if they will agree to change the behavior, or to add a new function.

PHP encodes `~`:
```php
echo urlencode('-._~'); # -._%7E
echo urlencode('~'); # %2F
```

Perl:
```perl
use URI::Escape;
print(uri_escape("-._~")); # -._~
print(uri_escape("/")); # %2F
```

Ruby:
```ruby
require "erb"
include ERB::Util
puts url_encode("-._~") # -._~
puts url_encode("/") # %2F
```

Go:
```go
package main

import (
        "fmt";
        "net/url";
)

func main() {
        fmt.Println(url.PathEscape("-._~")) # -._~
        fmt.Println(url.PathEscape("/")) # %2F
}
```

Java encodes `~`:
```java
import java.net.URLEncoder;
import java.io.UnsupportedEncodingException;

public class HelloWorld {
  public static void main(String[] args) {
    try {
     System.out.println(URLEncoder.encode("-._~", "UTF-8")); // -._%7E
     System.out.println(URLEncoder.encode("/", "UTF-8")); // %2F
    } catch (UnsupportedEncodingException e) {}
  }
}
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/369#issuecomment-380720933

Received on Thursday, 12 April 2018 08:27:04 UTC