473,779 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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=%System Root%\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 3307
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=%System Root%\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
7304
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
7484
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 characters themselves. Thus, my app may have SQL statements like: UPDATE table SET field1 = '<some string in Chinese>'; The syntax above works both in my app and through SQL Server Enterprise
5
8847
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 there a workaround? Do other .NET languages support code points > 0x10FFFF I appreciate any comments Thanks Johannes
5
5508
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 because the textbox obviously wraps the text so it does not include any escape characters, if i were to put it in code of the program like this: string s = "\ub7c6\ub9d1\ubbd9" it would have represented a unicode text.
12
3893
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, some Chinese characters are illegible( I see sizeof(TCHAR)=2 being displayed). Your idea is welcome. case WM_PAINT: hdc = BeginPaint(hWnd, &ps);
4
2509
by: Rehceb Rotkiv | last post by:
Hello, I have this little grep-like program: ++++++++++snip++++++++++ #!/usr/bin/python import sys import re
8
2411
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) == s mario
1
3575
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 = meta.encode('unicode-escape') when given an 8-bit string, (in meta), the code fragment above yields the error below. 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in range(128)
5
5334
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 converted to their character representation. They are shown excatly same way than in file. Literals in C# code's variables are shown corretly. Can anyone tell how to read Unicode escape sequences from file so that they
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.