skip to Main Content

I have been searching for a method of encoding url just like facebook’s. All I have been able to find is these methods:

escape
encodeURI
encodeURIComponent

The goal is to encode a string in latin characters, for example:

¿Cómo estás?

Facebook results in the next url
enter image description here

When I use the 3 functions I talked abour earlier I get nothing similar

escape("¿Cómo estás?"); //"%BFC%F3mo%20est%E1s%3F"
encodeURI("¿Cómo estás?");//"%C2%BFC%C3%B3mo%20est%C3%A1s?"
encodeURIComponent("¿Cómo estás?"); //"%C2%BFC%C3%B3mo%20est%C3%A1s%3F"

I need you to guide me to the solution, this is something im doing more than anything for SEO purposes. Do I have to code a function myself?

Thanks for your time.

2

Answers


  1. So my first guess is you are encoding in UTF-8 where Facebook may be encoding in ISO.

    https://en.wikipedia.org/wiki/ISO/IEC_8859-1 vs https://en.wikipedia.org/wiki/UTF-8

    As far as SEO goes – I do not see the relation, the example is just a query string – so wouldn’t be crawled by a search engine. I may be misunderstanding – hopefully that points you in the right direction though.

    Login or Signup to reply.
  2. After I decided to make my search just encoding my string using encodeURIComponent I discovered that when you window.location.href your encoded string your URL actually looks like facebooks. What a surprise, It looks very different in the console.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search