Solved

Problem with Javascript encodeURI in Chrome extension

Posted on 2010-11-23
2
491 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

759 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