Search the Site

Sponsors

bottom corner

Python ucs2 vs ucs4 installation

On Linux, Python installations default to the unicode representation of the OS environment (ucs2 vs ucs4). I sometimes find myself needing to reinstall python, forcing a different unicode representation, especially when I am given pre-compiled python binaries. Here are examples of using the --enable-unicode setting when building python. Also, there are some examples of how to determine which ucs setting your version of python is using.

This page is filed under keyword(s): python.

For forcing ucs4 when installing Python:

./configure --enable-unicode=ucs4
make
make install

For forcing ucs2 when installing Python:

./configure --enable-unicode=ucs2
make
make install

Once you have it installed, a ucs4 version will produce the following:

bash$ python
Python 2.5.2 (r252:60911, Mar  4 2008, 10:58:18)
[GCC 3.4.5] on linux
>>>import sys
>>> print sys.maxunicode
1114111

And, a ucs2 version will produce the following:

>>>import sys
>>> print sys.maxunicode
65535

Did you find this page useful? Please consider browsing other articles or subscribing to the RSS feed to keep up with latest.

This page is filed under keyword(s): python.
Author: J. Kim
Last updated: 15 Sep 2012

bottom corner