dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.11k stars 1.56k forks source link

Window.escape compatible encoder #14281

Open jbdeboer opened 10 years ago

jbdeboer commented 10 years ago

In AngularJS, we use window.escape to escape our cookie values:

From MDN, " Encodes a string, replacing all characters except for ASCII digits, lower and upper case letters, and the characters * + - . / @­ _ with a hexadecimal escape sequence. "

There should be an equivalent function in Dart so that we can share cookies between Dart and Javascript.

Note, there are other functions in Dart that "percent-encode", but since we have a limited number of bytes to store cookies, we can not be over-zealous in what we escape.

madsager commented 10 years ago

Added Area-Library, Triaged labels.

lrhn commented 10 years ago

Added Library-Convert label.

lrhn commented 10 years ago

The closest things in Dart are Uri.encodeFull and Uri.encodeComponent, but they don't omit the same characters, and they don't use %uxxxx encoding for >8-bit characters.

Would it be possible to use Uri.encodeComponent in Dart and encodeUriComponent in JS?


Removed Type-Defect label. Added Type-Enhancement label.