Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9086633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:32:12+00:00 2026-06-16T21:32:12+00:00

I am experimenting with the Twitter API for Python and have run into a

  • 0

I am experimenting with the Twitter API for Python and have run into a character encoding/decoding issue; when I am collecting tweets for a user (@BBCWorld in this instance), if there is special punctuation I receive the following error:

286952044814794753 :  Traceback (most recent call last):
  File "C:\Python27\lib\encodings\cp850.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u201c' in position 0: character maps to <undefined>

Note: The long number at the start is the ID of the tweet causing the error.

The specific character that is causing this problem is an angular (opening) double quotation mark (like those used in MS-Word). Is there a way to display such punctuation in a compatible form? Ideally I want to sanitise tweets to overcome this kind of error by use of replacement, therefore maintaining context, rather that omitting characters.

This is the core of the code:

tweets=api.GetUserTimeline('BBCWorld') 
try: 
    for tweet in tweets: 
        print tweet.id, ": ", (tweet.text) 
except UnicodeEncodeError as uee: 
    print uee

Thanks for any pointers,

Milutin

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:32:13+00:00Added an answer on June 16, 2026 at 9:32 pm

    This problem does not seem to be an issue of python-twitter or python for that matter – it’s a problem with Windows cmd.

    If you try this under a suitable Unix terminal, this is what you get:

    >>> import twitter
    >>> api = twitter.Api()
    >>> print api.GetStatus('286952044814794753').text
    “How do you change mindsets at a societal level, in a country of 1.2bn people?” - Viewpoints from India http://t.co/RiP4t71q #Delhigangrape
    

    Take a look at this question for a discussion of how to deal with this under Windows: Unicode not printing correctly to cp850 (cp437), play card suits

    My best bet for you would be to change your console font and codepage to a unicode compliant, as outlined here:
    https://stackoverflow.com/a/4234515/679897
    or here: http://www.velocityreviews.com/forums/t717717-python-unicode-and-windows-cmd-exe.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I experimenting with twitter streaming API, I use Phirehose to connect to twitter and
I'm experimenting with ASP.Net Web API, which, by convention, splits controller methods into a
I'm experitmenting with the Twitter API (OAuth). I have a test bed that can
I have a twitter feed displaying my tweets on a page. I want to
I'm experimenting with the Twitter streaming api, and am trying to open a stream
Experimenting with new features of T-SQL, I've run into a puzzle. Here is some
I experimenting with Flex Styling, and I came across an alignment issue. I have
Started experimenting with building classes, and I've began by converting my user registration/login into
After experimenting with many IMAP API's, I have decided to write my own (Most
I've been working with the twitter search api, retrieving tweets with a php script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.