fxa / uritemplate-js

An javascript implementation of RFC6570 Uri Templates
MIT License
97 stars 20 forks source link

Giving error in parsing some special characters #16

Open rohit-taneja opened 9 years ago

rohit-taneja commented 9 years ago

Code for this does encoding character wise. I am parsing this 💉 which is a 2 character symbol, now when it encode this character wise it gets ? or a box as the first character and gives an error

error: URIError: URI malformed at encodeURIComponent (native)

Runnig this in node terminal : encodeURIComponent("💉") gives result %F0%9F%92%89 which is the desired result but 💉 is 2 characters.

fxa commented 9 years ago

Could you please give me the char as hex codes? Your chars are malformed during my email client

On 29.03.2015 15:09, rthealthkart wrote:

Code for this does encoding character wise. I am parsing this 💉 which is a 2 character symbol, now when it encode this character wise it gets ? or a box as the first character and gives an error

error: URIError: URI malformed at encodeURIComponent (native)

Runnig this in node terminal : encodeURIComponent("💉") gives result %F0%9F%92%89 which is the desired result but 💉 is 2 characters.


Reply to this email directly or view it on GitHub: https://github.com/fxa/uritemplate-js/issues/16

Franz Antesberger Alexander Ferdinand Str 3 93051 Regensburg info@franz-antesberger.de 0160 374 84 95

rohit-taneja commented 9 years ago

Yes, The UTF-8 Hex code for 💉 is : F0 9F 92 89

fxa commented 9 years ago

Please be aware, that javascript does not use utf-8, but ucs-2. So all charCodes are between 0 and 65535. What is your exact input, your expected output and your actual output (I think, an exception)

On 30.03.2015 09:08, rthealthkart wrote:

Yes, The UTF-8 Hex code for 💉 is : F0 9F 92 89


Reply to this email directly or view it on GitHub: https://github.com/fxa/uritemplate-js/issues/16#issuecomment-87574499

Franz Antesberger Alexander Ferdinand Str 3 93051 Regensburg info@franz-antesberger.de 0160 374 84 95

rohit-taneja commented 9 years ago

This is the code point link of the above special character syringe : https://codepoints.net/U+1F489 The query parameter that I am sending in the url is ?name=%F0%9F%92%89 And Node.js Express3 decodes it via UTF-8 and the result is symbol 💉 of length 2 charcaters (4 bytes). But Uritemplate encodes it using 1 character (UCS-2) and gives 500 error. Is there a way to tell Uritemplate to use a specific ecoding standard.