itamar
itamar

Reputation: 1940

javascript encodeURI() output

According to MDN, The 'encodeURI()' function:

replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character

However, when invoking encodeURI('\u0082') (in Chrome) Im getting %C2%81 as output.

I expected to get %82 or %00%82. What does the %C2 mean?

Upvotes: 0

Views: 174

Answers (2)

Florian Straub
Florian Straub

Reputation: 856

Decoding %C2 at http://www.albionresearch.com/misc/urlencode.php leads to Â

When dealing with German texts and ISO 8859-15 / ISO 8859-1 vs. UTF-8 I often ran into the à character. The characters are quite close to each other. May this also be an encoding problem?

Maybe HTML encoding issues - "Â" character showing up instead of " " helps.

Upvotes: 0

itamar
itamar

Reputation: 1940

The '0082' in '\u0082' is the Unicode code point, not the UTF-8 bytes representation. UTF-8 maps u+0082 code point to two bytes: C2+81

Unicode to UTF-8 mapping table

Upvotes: 1

Related Questions