Solved

Problem with Javascript encodeURI in Chrome extension

Posted on 2010-11-23
2
492 Views
Last Modified: 2012-05-10
I have the following Javascript Code in my Chrome extension:

--snip--
console.log("title: "+title);
console.log("body: "+body);
var s = encodeURI(title);
console.log("s: "+s);
--snip

The URL that the extension processes is: http://de.wikipedia.org/wiki/Robert_Louis_Stevenson
title is tab.title from the active tab.

The console output is:

title: Robert Louis Stevenson – Wikipedia
body: http://de.wikipedia.org/wiki/Robert_Louis_Stevenson
s: Robert%20Louis%20Stevenson%20%E2%80%93%20Wikipedia

My question is, why is the minus char "-" converted to %E2%80%93 in this case? What does this mean?

If I try the same code on a different URL, for example the same Wikipedia page in English instead of German: http://en.wikipedia.org/wiki/Robert_Louis_Stevenson

the output is like this:

title: Robert Louis Stevenson - Wikipedia, the free encyclopedia
body: http://en.wikipedia.org/wiki/Robert_Louis_Stevenson
s: Robert%20Louis%20Stevenson%20-%20Wikipedia,%20the%20free%20encyclopedia

This time the minus char "-" is not converted at all.

I guess it may have something to do with a Unicode convertion, but both these pages are encoded with UTF-8 according to the page sources.

So all in all I want to know the exact meaning why a minus char is converted to E2%80%93% in encodeURI().
0
Comment
Question by:dMa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 250 total points
ID: 34202993
In this case the - is no minus it's a long minuns (e.g in word the char you get if you type three -, or in html it's the entitiy –)
0
 
LVL 2

Author Comment

by:dMa
ID: 34203109
What is the difference between – and the ASCII - (code 45)? Why is it displayed as %E2%80%93, due to what convention?
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question