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

  • Home
  • SEARCH
  • 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 6173097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:30:30+00:00 2026-05-23T23:30:30+00:00

For the first time, I was trying out one of my Python scripts, which

  • 0

For the first time, I was trying out one of my Python scripts, which deals with unicode characters, on Windows (Vista) and found that it’s not working. The script works perfectly okay on Linux and OS X but no joy on Windows. Here is the little script that I tried:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import os, sys, codecs

reload(sys)
sys.setdefaultencoding('utf-8')
print "\nDefault encoding\t: %s" % sys.getdefaultencoding()
print "sys.stdout.encoding\t: %s\n" % sys.stdout.encoding

## Unicode strings
ln1 = u"?0>9<8~7|65\"4:3}2{1+_)(*&^%$£@!/`\\][=-"
ln2 = u"mnbvc xzasdfghjkl;'poiuyàtrewq€é#¢."

refStr = u"%s%s" % (ln2,ln1)
print "refSTR: ", refStr

for x in refStr:
    print "%s => %s" % (x, ord(u"%s" % x))

When I run the script from Windows CLI, I get this error:

C:\Users\san\Scripts>python uniCode.py

Default encoding        : utf-8
sys.stdout.encoding     : cp850

refSTR;  Traceback (most recent call last):
  File "uniCode.py", line 18, in <module>
    print "refSTR; ", refStr
  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'\u20ac' in position
 30: character maps to <undefined>

I came across this Python-wiki and tried a few things from there but that didn’t work. Does anyone know what I’m still missing? Any help greatly appreciated. Cheers!!

  • 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-05-23T23:30:30+00:00Added an answer on May 23, 2026 at 11:30 pm

    The Windows console has a Unicode API, but not utf-8. Python is trying to encode Unicode characters to your console’s 8-bit code page cp850, which obviously won’t work. There’s supposedly a code page (chcp 65001) in the Windows console that supports utf-8, but it’s severely broken. Read issue 1602 and look at sys_write_stdout.patch and unicode2.py, which use Unicode wide character functions such as WriteConsoleOutputW and WriteConsoleW. Unfortunately it’s a low priority issue.

    FYI, you can also use IDLE, or another GUI console (based on pythonw.exe), to run a script that outputs Unicode characters. For example:

    C:\pythonXX\Lib\idlelib\idle.pyw -r script.py
    

    But it’s not a general solution if you need to write CLI console tools.

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

Sidebar

Related Questions

I am trying out seeds.rb for the first time, and one of my data
I'm trying out Windows Phone 7 dev for the first time. I decided to
I'm trying out Linq for the first time and having a bit of difficult
Alright, so I'm trying out C++ for the first time, as it looks like
I'm first time poster here trying to pick up some Python skills; please be
I'm trying out some jQuery for the first time. My first goal is for
I am trying out using fragments with my tabhost for the first time and
I'm trying out stored procedures for the first time, and I can't figure out
first time SO user :) I know that I can format a number like
I'm learning Python as my second programming language (my first real one if you

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.