Take the 2-minute tour ×

I'm writing a web crawler in python, and it involves taking headlines from websites.

One of the headlines should've read : And the Hip's coming, too

But instead it said: And the Hipâ€™s coming, too

What's going wrong here?

share|improve this question
It would be easier to help you if you included the relevant code, and the particular website you're parsing. –  jbowes Oct 28 '12 at 16:27

2 Answers 2

up vote 3 down vote accepted

You need to properly decode the source text. Most likely the source text is in UTF-8 format, not ASCII.

Because you do not provide any context or code for your question it is not possible to give a direct answer.

I suggest you study how unicode and character encoding is done in Python:


share|improve this answer
Yes, it's UTF-8 treated like Windows 1252: u'\N{RIGHT SINGLE QUOTATION MARK}'.encode('utf-8').decode('cp1252'). –  eryksun Oct 28 '12 at 16:27

It's an encoding error - so if it's a unicode string, this ought to fix it:


If it's a plain string, you'll need an extra step:


Both of these will give you a unicode string.

By the way - to discover how a piece of text like this has been mangled due to encoding issues, you can use chardet:

>>> import chardet
>>> chardet.detect(u"And the Hipâ€™s coming, too")
{'confidence': 0.5, 'encoding': 'windows-1252'}
share|improve this answer

Your Answer


