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 9259589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:41:35+00:00 2026-06-18T12:41:35+00:00

Since Python 2.2 and PEP 261 , Python can be built in narrow or

  • 0

Since Python 2.2 and PEP 261, Python can be built in “narrow” or “wide” mode, which affects the definition of a “character”, i.e. “the addressable unit of a Python Unicode string”.

Characters in narrow builds look like UTF-16 code units:

>>> a = u'\N{MAHJONG TILE GREEN DRAGON}'
>>> a
u'\U0001f005'
>>> len(a)
2
>>> a[0], a[1]
(u'\ud83c', u'\udc05')
>>> [hex(ord(c)) for c in a.encode('utf-16be')]
['0xd8', '0x3c', '0xdc', '0x5']

(The above seems to disagree with some sources that insist that narrow builds use UCS-2, not UTF-16. Very intriguing indeed)

Does Python 3.0 keep this distinction? Or are all Python 3 builds wide?

(I’ve heard about PEP 393 that changes internal representation of strings in 3.3, but this doesn’t relate to 3.0 ~ 3.2.)

  • 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-18T12:41:36+00:00Added an answer on June 18, 2026 at 12:41 pm

    Yes, from 3.0 to 3.2 they do. Windows uses narrow builds while (most) Unix uses wide builds

    Using Python 3.2 on Windows:

    >>> a = '\N{MAHJONG TILE GREEN DRAGON}'
    >>> len(a)
    2
    >>> a
    ''
    

    While this behavior is expected on 3.3+ using Windows:

    >>> a = '\N{MAHJONG TILE GREEN DRAGON}'
    >>> len(a)
    1
    >>> a
    '\U0001f005'
    >>> print(a)
    Traceback (most recent call last):
      File "<pyshell#3>", line 1, in <module>
        print(a)
    UnicodeEncodeError: 'UCS-2' codec can't encode character '\U0001f005' 
    in position 0: Non-BMP character not supported in Tk
    

    The UCS-2 codec is used on Tk (I’m using IDLE – the terminal may show another error).

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

Sidebar

Related Questions

PEP 8 says that Python package and module names should be short, since some
Since Python's string can't be changed, I was wondering how to concatenate a string
Very simple question: Specifically in Python (since Python actually has strongly recommended style guidelines
I'm using Python since some times and I am discovering the pythonic way to
Since functions are values in Python, how do I determine if the variable is
Since a few weeks I am learning Python and Django. Up to this point
I want a Python object that will monitor whether other objects have changed since
I have a simple python program that I'd like to daemonize. Since the point
I am relatively new in python, was working on C a lot. Since I
I want to start coding in Python or Ruby. Since I own a Lego

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.