HTML escaping and percent-encoding


HTML escaping

used to escape &, <, > and " in HTML document.

encode (escape, html-escape)

Rails

Phoenix

  1. https://github.com/martinsvalin/html_entities

decode (unescape)

Rails

Phoenix

percent-encoding (percent-escaping, URL encoding)

  1. https://en.wikipedia.org/wiki/Percent-encoding

used to encode both URLs (primarily query strings) and HTML form data of application/x-www-form-urlencoded media type (in the latter case reserved characters are always encoded).

test URL: http://test.com?q1=foo,bar&q2=http://foo.com.

encode (percent-encode, escape, percent-escape)

Rails

Phoenix

decode (percent-decode, unescape, percent-unscape)

all decode functions in both Rails and Phoenix decode ALL escaped characters - they differ only in how they return the result (string, hash or array of arrays).

Rails

Phoenix