Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle encoding / decoding #5

Open
alex-wilmer opened this issue Nov 4, 2018 · 5 comments
Open

handle encoding / decoding #5

alex-wilmer opened this issue Nov 4, 2018 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@alex-wilmer
Copy link
Member

questions with special characters need to be encoded:

image

responses with special characters need to be decoded:

image

@alex-wilmer alex-wilmer added help wanted Extra attention is needed good first issue Good for newcomers enhancement New feature or request labels Nov 4, 2018
@owenip
Copy link

owenip commented Nov 7, 2018

May I work on this issue? Thinking of using regex to decode the special characters.

@mihok
Copy link
Member

mihok commented Nov 7, 2018

Yas! Go for it @owenip

@owenip
Copy link

owenip commented Nov 8, 2018

Hey @mihok , @alex-wilmer ,
I am wondering how many special characters should be supported. Please see HTML named character References.

Current Approaches for most common special characters

function unescapeHtml(text) {
  return text
    .replace(/&/g, '&')
    .replace(/&lt;/g, "<")
    .replace(/&gt;/g, ">")
    .replace(/&quot;/g, "\"")
    .replace(/&#039;/g, "'");
}

@alex-wilmer
Copy link
Member Author

Isn't encodeURI and decodeURI sufficient for this?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI

@owenip
Copy link

owenip commented Nov 8, 2018

Not Escaped:
A-Z a-z 0-9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) #

encodeURI doesn't handle those characters.

Also stackOverflow api return named characters which could not be converted by decodeURI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants