Random quote machine problem with quote

I have a problem with the text to be shared, when the quote have a ’ the share is cut before that '.
I am reading and searching but I cant find how to solve that.

You have to encode the text. Use encodeUriComponent().

Nice to have an answer here, Thank you. I got the same answer on fullstack overflow and solved the problem.