472,961 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

Windows XP unicode and escape sequences

I mainly work on OS X, but thought I'd experiment with some Python code on XP. The
problem is I can't seem to get these things to work at all.

First of all, I'd like to use Greek letters in the command prompt window, so I was going to
use unicode to do this. But in the command prompt, the unicode characters are displaying
as strange looking characters. I tried installing the 'Bitstream Vera Sans Mono' font in hopes
it had all the characters I needed but this didn't seem to work either. Is the problem the font?
And if so, is there a certain font that has unicode '03B1', etc? Here's some code I tried:

v = u'\u03B1\u03B2\u03B3'.encode('utf-8')
print v #just displays squares

The next problem I'm having is I can't seem to color the text with ansi escape sequences. I
added "device=%SystemRoot%\system32\ansi.sys" to the bottom of the CONFIG.NT file, and experimented with code like this:

print chr(27) + "[36mTest" + chr(27) + "[0m"
>From what I found on-line, ascii character 27 seems to be the escape key I need, but I can't
seem to get it to work. It just displays an arrow.

If anyone has any thoughts, I'd love to hear them.

Thanks!

Jay
Dec 12 '07 #1
2 3255
On Dec 12, 2:51 pm, <jyoun...@kc.rr.comwrote:
I mainly work on OS X, but thought I'd experiment with some Python code on XP. The
problem is I can't seem to get these things to work at all.

First of all, I'd like to use Greek letters in the command prompt window, so I was going to
use unicode to do this. But in the command prompt, the unicode characters are displaying
as strange looking characters. I tried installing the 'Bitstream Vera Sans Mono' font in hopes
it had all the characters I needed but this didn't seem to work either. Is the problem the font?
And if so, is there a certain font that has unicode '03B1', etc? Here's some code I tried:

v = u'\u03B1\u03B2\u03B3'.encode('utf-8')
print v #just displays squares
You've got two problems. First, you don't need to encode it; if the
command prompt window displayed your output after encoding it would
display the multi-byte form of your characters. You should just send
it a unicode object.

Second, check the .encoding attribute of the sys.stdout object.
Therein lies enlightenment about what the command prompt window will
accept.

No info on your other problem.

John Roth
>
If anyone has any thoughts, I'd love to hear them.

Thanks!

Jay
Dec 14 '07 #2
<jy******@kc.rr.comwrote:
>I mainly work on OS X, but thought I'd experiment with some Python code on XP. The
problem is I can't seem to get these things to work at all.

First of all, I'd like to use Greek letters in the command prompt window, so I was going to
use unicode to do this. But in the command prompt, the unicode characters are displaying
as strange looking characters. I tried installing the 'Bitstream Vera Sans Mono' font in hopes
it had all the characters I needed but this didn't seem to work either. Is the problem the font?
And if so, is there a certain font that has unicode '03B1', etc? Here's some code I tried:
It's not the font. (OK, it's partially the font.) To display Greek
characters to the console, your console session has to be set for a code
page that includes Greek characters.
>The next problem I'm having is I can't seem to color the text with ansi escape sequences. I
added "device=%SystemRoot%\system32\ansi.sys" to the bottom of the CONFIG.NT file, and experimented with code like this:

print chr(27) + "[36mTest" + chr(27) + "[0m"

From what I found on-line, ascii character 27 seems to be the escape key I need, but I can't
seem to get it to work. It just displays an arrow.
CONFIG.NT only affects 16-bit programs running in the NTVDM (the Virtual
DOS Machine).

32-bit console apps (which Python is) simply cannot use ANSI escape
sequences. You have to use the Win32 APIs to do color. There are
curses-like libraries available for Python. Or:

http://www.effbot.org/zone/console-handbook.htm
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Dec 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: harrelson | last post by:
I have a list of about 2500 html escape sequences (decimal) that I need to convert to utf-8. Stuff like: 비 행 기 로 보 낼 거
2
by: Silvio Lopes de Oliveira | last post by:
Hello, I use Unicode in my program to enter data in Chinese into a nvarchar field. When inserting or updating records, my application does not use Unicode escape sequences but rather the Unicode...
5
by: Johannes | last post by:
Is it correct that Unicode characters with code points above 0x10FFFF are not supported by C# I have a hard time believing this since it would eliminate some Asian languages. If it is true, is...
5
by: Jonathan Seidner | last post by:
Hi, I have a program which contains a textbox, in this text box the user types this string: "\ub7c6\ub9d1\ubbd9\ubdc8\ubfcb\uc1b2\uc3a7\uc586\uc7a9\uc9b0\ucbfb" this is NOT a unicode string...
12
by: Onega | last post by:
Hi I create a simple win32 project (VC2003, windows2003(English) , and do simple paint in WM_PAINT message, when the project use multi-character set, it is OK. but when I change to UNICODE,...
4
by: Rehceb Rotkiv | last post by:
Hello, I have this little grep-like program: ++++++++++snip++++++++++ #!/usr/bin/python import sys import re
8
by: mario | last post by:
I have checks in code, to ensure a decode/encode cycle returns the original string. Given no UnicodeErrors, are there any cases for the following not to be True? unicode(s, enc).encode(enc)...
1
by: Eric S. Johansson | last post by:
I'm having a problem (Python 2.4) converting strings with random 8-bit characters into an escape form which is 7-bit clean for storage in a database. Here's an example: body =...
5
by: John Ztwin | last post by:
Hello, I have a file that contains ordinary text and some special charaters in Unicode escape sequences (\uxxxx). When I read the file using e.g. StreamReader Unicode escape sequences are not...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.