473,807 Members | 2,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can i write a hello world in chinese with python

I'm try to build a bundle on OS X, so I write a simple python script
for a test:

#!/usr/bin/env python
import EasyDialogs
EasyDialogs.Mes sage("Hello,Mac !")
This runs OK,but when I try to replace "Hello,Mac! " with chinese, it
can't be display rightly.
Then I tried some way else:

#!/usr/bin/env python
import EasyDialogs
EasyDialogs.Mes sage("\xe4\xb8\ xad")

It doesn't work!

As I know mac is unicode based,how can I display chinese on the screen?

Dec 13 '06 #1
7 2149
try unicode?

"kernel1983 дµÀ£º
"
I'm try to build a bundle on OS X, so I write a simple python script
for a test:

#!/usr/bin/env python
import EasyDialogs
EasyDialogs.Mes sage("Hello,Mac !")
This runs OK,but when I try to replace "Hello,Mac! " with chinese, it
can't be display rightly.
Then I tried some way else:

#!/usr/bin/env python
import EasyDialogs
EasyDialogs.Mes sage("\xe4\xb8\ xad")

It doesn't work!

As I know mac is unicode based,how can I display chinese on the screen?
Dec 13 '06 #2
and I tried unicode and utf-8
I tried to both use unicode&utf-8 head just like "\xEF\xBB\x BF" and not
to use

Anyone knows about the setting in the python code file?
Maybe python doesn't know I'm to use chinese?!

On 12ÔÂ13ÈÕ, ÏÂÎç12ʱ47·Ö, "bearsprite " <bearspr...@gma il.com>
wrote:
try unicode?

"kernel1983 дµÀ£º
"
I'm try to build a bundle on OS X, so I write a simple python script
for a test:
#!/usr/bin/env python
import EasyDialogs
EasyDialogs.Mes sage("Hello,Mac !")
This runs OK,but when I try to replace "Hello,Mac! " with chinese, it
can't be display rightly.
Then I tried some way else:
#!/usr/bin/env python
import EasyDialogs
EasyDialogs.Mes sage("\xe4\xb8\ xad")
It doesn't work!
As I know mac is unicode based,how can I display chinese on the screen?
Dec 13 '06 #3

kernel1983 wrote:
and I tried unicode and utf-8
How did you try unicode? Like this? :

EasyDialogs.Mes sage(u'\u4e2d')
I tried to both use unicode&utf-8 head just like "\xEF\xBB\x BF" and not
to use

Anyone knows about the setting in the python code file?
Maybe python doesn't know I'm to use chinese?!
It depends on how EasyDialogs works. And by the way, when you say utf-8
encoded text is not displayed correctly, what do you actually see on
the screen?

-- Leo

Dec 13 '06 #4

Leo Kislov wrote:
kernel1983 wrote:
and I tried unicode and utf-8

How did you try unicode? Like this? :

EasyDialogs.Mes sage(u'\u4e2d')
I tried to both use unicode&utf-8 head just like "\xEF\xBB\x BF" and not
to use

Anyone knows about the setting in the python code file?
Maybe python doesn't know I'm to use chinese?!

It depends on how EasyDialogs works. And by the way, when you say utf-8
encoded text is not displayed correctly, what do you actually see on
the screen?
There is a Windows version of EasyDialogs -- unfortunately it appears
not to support Unicode, even for the most simple case.

This works:
| >>EasyDialogs.M essage('fubar')
but this doesn't:
| >>EasyDialogs.M essage(u'fubar' )

The title of the window is empty, the text consists of only 'f", and
there is no OK button.
Not very robust.

Dec 13 '06 #5
kernel1983 wrote:
I'm try to build a bundle on OS X, so I write a simple python script
for a test:

#!/usr/bin/env python
import EasyDialogs
EasyDialogs.Mes sage("Hello,Mac !")
This runs OK,but when I try to replace "Hello,Mac! " with chinese, it
can't be display rightly.
Then I tried some way else:

#!/usr/bin/env python
import EasyDialogs
EasyDialogs.Mes sage("\xe4\xb8\ xad")

It doesn't work!

As I know mac is unicode based,how can I display chinese on the screen?
EasyDialogs is an *ancient* module on OS X--it may not support unicode.
Try posting to the MacPython list, someone there can verify this.

--Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Dec 13 '06 #6

Dennis Lee Bieber wrote:
On 12 Dec 2006 23:40:41 -0800, "kernel1983 " <ke********@gma il.com>
declaimed the following in gmane.comp.pyth on.general:
and I tried unicode and utf-8
I tried to both use unicode&utf-8 head just like "\xEF\xBB\x BF" and not
to use
"unicode" is a term covering many sins. "utf-8" is a specification
for encoding elements of specific unicode characters using 8-bit
elements (I believe by using certain codes x00 to x7F alone as "normal",
and then x80 to xFF to represent an "escape" to higher [16-bit] element
sets).

"\xEF\xBB\x BF" is just a byte string with no identifier of what
encoding is in use (unless the first one or two are supposed to be
BOM)... In the "Windows: Western" character set, it is equivalent to
small-i-diaeresis/right-guillemot/upside-down? () In MS-DOS: Western
Europe, those same bytes represent an
acute-accent/double-down&left-box-drawing/solid-down&left

I've not done any unicode work (iso-latin-1, or subset thereof, has
done for me). I also don't know Mac's, so I don't know if the windowing
API has specific calls for Unicode data... But you probably have to
encode or decod that bytestring into some compatible unicode
representation.
When you save a textfile as UTF-8 in Notepad.exe (Windows) it puts the
bytestring "\xEF\xBB\x BF" at the start to indicate that it's UTF-8 and
not ANSI (ie 8-bit characters). The bytes are actually the BOM
bytestring "\xFE\xFF" encoded in UTF-8.

Dec 14 '06 #7
thanks everyone
maybe this simple API doesn't fit the Chinese display
but thanks everybody!

At least I've got that what bundles is and maybe I can use Python to
write program

On 12ÔÂ14ÈÕ, ÉÏÎç6ʱ31·Ö, "MRAB" <goo...@mrabarn ett..plus.com>
wrote:
Dennis Lee Bieber wrote:
On 12 Dec 2006 23:40:41 -0800, "kernel1983 " <kernel1...@gma il.com>
declaimed the following in gmane.comp.pyth on.general:
and I tried unicode and utf-8
I tried to both use unicode&utf-8 head just like "\xEF\xBB\x BF" and not
to use
"unicode" is a term covering many sins. "utf-8" is a specification
for encoding elements of specific unicode characters using 8-bit
elements (I believe by using certain codes x00 to x7F alone as "normal",
and then x80 to xFF to represent an "escape" to higher [16-bit] element
sets).
"\xEF\xBB\x BF" is just a byte string with no identifier of what
encoding is in use (unless the first one or two are supposed to be
BOM)... In the "Windows: Western" character set, it is equivalent to
small-i-diaeresis/right-guillemot/upside-down? () In MS-DOS: Western
Europe, those same bytes represent an
acute-accent/double-down&left-box-drawing/solid-down&left
I've not done any unicode work (iso-latin-1, or subset thereof, has
done for me). I also don't know Mac's, so I don't know if the windowing
API has specific calls for Unicode data... But you probably have to
encode or decod that bytestring into some compatible unicode
representation. When you save a textfile as UTF-8 in Notepad.exe (Windows) it puts the
bytestring "\xEF\xBB\x BF" at the start to indicate that it's UTF-8 and
not ANSI (ie 8-bit characters). The bytes are actually the BOM
bytestring "\xFE\xFF" encoded in UTF-8.
Dec 16 '06 #8

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

Similar topics

1
7036
by: Posadas, Dennis | last post by:
Hi, I've done some google searching w/c referred me to a couple of articles on unicode, but I'm looking for something really simple - not for a web application. See my sample code below. Any ideas how to convert it to display maybe Simplified Chinese ? Rgds,
1
2986
by: Anthony Liu | last post by:
The following 4 lines of code parses an XML document very well if the XML document contains only English words. But when I insert one Chinese character into the XML document, then Python starts to complain when it hits the Chinese character, saying that it is an invalid token and thus it is not well-formed. This is the complaint of Python:
33
3500
by: Nick Evans | last post by:
Hello there, I have been on and off learning to code (with python being the second language I have worked on after a bit of BASIC). What I really want to know is, if you are going to actually write a program or a project of some sort, how do you actually start. Picture this, you know what you want the program to do (its features), you have a possably rough idea of how the program will work. You have opened an empty text file and saved...
1
2366
by: Anthony Liu | last post by:
I believe that topic related to Chinese processing was discussed before. I could not dig out the info I want from the mail list archive. My Python script reads some Chinese text and then split a line delimited by white spaces. I got lists like
2
1242
by: =?gb2312?B?u7W1sA==?= | last post by:
It's really annoying to find there are all English language posts here because I wanna talk about something about the Chinese related programs. Could you give me some ?
1
3254
by: James T. Dennis | last post by:
You'd think that using things like gettext would be easy. Superficially it seems well documented in the Library Reference(*). However, it can be surprisingly difficult to get the external details right. * http://docs.python.org/lib/node738.html Here's what I finally came up with as the simplest instructions, suitable for an "overview of Python programming" class: Start with the venerable "Hello, World!" program ... slightly modified
12
2747
by: Steve Howell | last post by:
The never-ending debate about PEP 3131 got me thinking about natural languages with respect to Python, and I have a bunch of mostly simple observations (some factual, some anecdotal). I present these mostly as food for thought, but I do make my own continent-by-continent recommendations at the bottom of the email. (My own linguistic biases are also disclosed at the bottom of the email.) Nationality of various technologists who use...
0
4614
by: devito | last post by:
hi there, for some days i try to build the boost.python tutorial "hello world" without bjam on winxp by using mingw. so i wrote a *.bat-file like the following: // --- snip -------------------------------------------------------------------------------------- @echo off SETLOCAL
0
1486
by: Gerardo Herzig | last post by:
Hi all. Im having some "problems" with a small concurrent plpython function. Based on a small example about concurrent programming, there is some code which works fine under python: #! /usr/bin/python import threading, random import time def myPrint(str):
0
9720
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
9599
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
10626
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
10372
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...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
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
5546
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
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
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

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.