The following perl program works when I run it from urxvt-X console on
cygwin-x windows
LC_CTYPE=en_US. UTF-8 urxvt-X.exe&
perl -wle "binmode STDOUT, q[:utf8]; print chr() for 0x410 .. 0x430;"
This little one liner prints the Russian alphabet in Cryllic. With some
slight modification it will also print a lot of other alphabets too --
including Hebrew, chinese and japanese.
It does not work with cmd.exe because apparently cmd.exe cannot deal with
UTF-8.
Can someone help me translate it into python? I would not expect it to work
from cmd.exe with python, but I am hopeful it will work with urxvt-X!
Thanks,
Siegfried 8 7023
LC_CTYPE=en_US. UTF-8 urxvt-X.exe&
perl -wle "binmode STDOUT, q[:utf8]; print chr() for 0x410 .. 0x430;"
Can someone help me translate it into python?
LC_CTYPE=en_US. UTF-8 urxvt-X.exe&
python -c 'for i in range(0x410, 0x431):print unichr(i),'
I would not expect it to work
from cmd.exe with python
It should work in cmd.exe, as long as the terminal's encoding supports
these characters in the first place. Use chcp.exe to find out what the
terminal's encoding is. The Python program is not completely equivalent,
as it leaves the output encoding to Python, rather than assuming a fixed
UTF-8 output encoding.
Regards,
Martin
""Martin v. Löwis"" <ma****@v.loewi s.dewrote in message
news:48******** **************@ news.freenet.de ...
>LC_CTYPE=en_US .UTF-8 urxvt-X.exe& perl -wle "binmode STDOUT, q[:utf8]; print chr() for 0x410 .. 0x430;"
>Can someone help me translate it into python?
LC_CTYPE=en_US. UTF-8 urxvt-X.exe&
python -c 'for i in range(0x410, 0x431):print unichr(i),'
>I would not expect it to work from cmd.exe with python
It should work in cmd.exe, as long as the terminal's encoding supports
these characters in the first place. Use chcp.exe to find out what the
terminal's encoding is. The Python program is not completely equivalent,
as it leaves the output encoding to Python, rather than assuming a fixed
UTF-8 output encoding.
Regards,
Martin
Make sure you are using the Lucida Console font for the cmd.exe window and
type the commands:
chcp 1251
python -c "print ''.join(unichr( i) for i in range(0x410,0x4 31))"
Output:
АБВГДЕЖ ИЙКЛМНО П*СТУФХ ЧШЩЪЫЬ* ЮЯа
UTF-8 encoding (chcp 65001) doesn't work (Python doesn't recognize it:
"LookupErro r: unknown encoding: cp65001") and I couldn't get any Chinese
code pages to work either. There is some trick I don't know, because
Chinese versions of Windows can display Chinese. I have the East Asian
languages installed and Chinese IME enabled, but it doesn't help for console
apps.
--Mark
>Make sure you are using the Lucida Console font for the cmd.exe window and type the commands:
chcp 1251 python -c "print ''.join(unichr( i) for i in range(0x410,0x4 31))"
Output:
?????????????? ??????????????? ????
Wowa! I was not aware of that chcp command! Thanks! How could I do that
"chcp 1251" programatically ?
The code was a little confusing because those two apostrophes look like a
double quote!
But what are we doing here? Can you convince me that we are emitting UTF-8?
I need UTF-8 because I need to experiment with some OS function calls that
give me UTF-16 and I need to emit UTF-16 or UTF-8.
I think part of the problem is that Lucida Console is not as capable as
"Arial Unicode MS" or the fonts used by urxvt-X.
Thanks,
Siegfried
On Wed, 01 Oct 2008 08:17:15 -0700, Siegfried Heintze wrote:
(snip)
The code was a little confusing because those two apostrophes look like
a double quote!
Tips: use mono-spaced font. There is no ambiguity.
(snip)
I think part of the problem is that Lucida Console is not as capable as
"Arial Unicode MS" or the fonts used by urxvt-X.
Thanks,
Siegfried
Why don't you write it to a file? Then open that file from Notepad
But what are we doing here? Can you convince me that we are emitting UTF-8?
Most definitely not. We are emitting cp1251.
I need UTF-8 because I need to experiment with some OS function calls that
give me UTF-16 and I need to emit UTF-16 or UTF-8.
Try setting the code page to 65001, and emit the UTF-8 explicitly.
Regards,
Martin
I need UTF-8 because I need to experiment with some OS function calls that
give me UTF-16 and I need to emit UTF-16 or UTF-8.
<ma****@v.loewi s.dewrote:
>Try setting the code page to 65001, and emit the UTF-8 explicitly.
Hmm... apparently that's not allowed on Windows XP:
C:\chcp 65001
Active code page: 65001
C:\python -c "for i in range(0x410, 0x430): print unichr(i).encod e('utf-8')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
IOError: [Errno 13] Permission denied
This works though:
C:\python -c "for i in range(0x410, 0x430): print unichr(i).encod e('utf-8')" x
C:\type x
[a bunch of Cyrillic letters]
Hmm... "more x" doesn't work, while "copy x con" works but gives an error.
Looks like Windows XP support UTF-8 console output is a bit half-assed.
Ross Ridge
--
l/ // Ross Ridge -- The Great HTMU
[oo][oo] rr****@csclub.u waterloo.ca
-()-/()/ http://www.csclub.uwaterloo.ca/~rridge/
db //
"Ross Ridge" <rr****@csclub. uwaterloo.cawro te in message
news:gc******** **@rumours.uwat erloo.ca...
>I need UTF-8 because I need to experiment with some OS function calls that give me UTF-16 and I need to emit UTF-16 or UTF-8.
<ma****@v.loewi s.dewrote:
>>Try setting the code page to 65001, and emit the UTF-8 explicitly.
Hmm... apparently that's not allowed on Windows XP:
C:\chcp 65001
Active code page: 65001
C:\python -c "for i in range(0x410, 0x430): print
unichr(i).encod e('utf-8')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
IOError: [Errno 13] Permission denied
This works though:
C:\python -c "for i in range(0x410, 0x430): print
unichr(i).encod e('utf-8')" x
C:\type x
[a bunch of Cyrillic letters]
Hmm... "more x" doesn't work, while "copy x con" works but gives an error.
Looks like Windows XP support UTF-8 console output is a bit half-assed.
It is odd, though, that when the code page (and font) are correct,
redirecting to a file and typing it work, but printing the result to the
console does not
"Siegfried Heintze" <si*******@hein tze.comwrote in message
news:vL******** *************** *******@comcast .com...
>
>>Make sure you are using the Lucida Console font for the cmd.exe window and type the commands:
chcp 1251 python -c "print ''.join(unichr( i) for i in range(0x410,0x4 31))"
Output:
????????????? ??????????????? ?????
Wowa! I was not aware of that chcp command! Thanks! How could I do that
"chcp 1251" programatically ?
The code was a little confusing because those two apostrophes look like a
double quote!
But what are we doing here? Can you convince me that we are emitting
UTF-8? I need UTF-8 because I need to experiment with some OS function
calls that give me UTF-16 and I need to emit UTF-16 or UTF-8.
I think part of the problem is that Lucida Console is not as capable as
"Arial Unicode MS" or the fonts used by urxvt-X.
In this case, it is not emitting UTF-8. It is emitting the windows-1251
encoding. As another poster mentioned, the Windows console gets an error
when attempting to write UTF8 when the code page is 65001 (UTF8). But you
can write output to a file explicitly in UTF-8 or UTF-16 and view the file
with Notepad. I've used this method for processing Chinese.
>>import os,codecs data = u''.join(unichr (i) for i in range(0x410,0x4 31)) codecs.open(' out.txt','wt',' utf-8').write(data) os.startfile( 'out.txt')
P.S.
One way to set the code page programmaticall y is to use ctypes, but this
will only work in a Windows console:
>>import ctypes k=ctypes.WinD LL('kernel32') x.SetConsoleO utputCP(1251)
1
>>print u''.join(unichr (i) for i in range(0x410,0 x430)).encode(' windows-1251')
АБВГДЕЖ ИЙКЛМНО П*СТУФХ ЧШЩЪЫЬ* ЮЯ
--Mark This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nigel Sampson |
last post by:
ey all,
I'm in the process of creating a method of
tracking whenever an objects properties are changed. Since
its not possible to alter
existing types I decided to used a proxy generated using
Reflection.Emit which inherits from the object needed
Person p = (Person)ProxyBuilder.Construct(typeof(Person));
|
by: DEK |
last post by:
I'm creating a dynamic assembly which has one type with one constructor,
the type inherits a base class Season, which is in the current assembly.
I am trying to emit a constructor which simply calls the base
constructor with the 4 args passed in, but I get this error Message at
the second last line of the method CreateSeason (Marked with...
|
by: Mark Miller |
last post by:
I am using Reflection.Emit to dynamically build a class. A method of the
class to be built requires a Parameter of type "Type". But I don't know how
to use Emit to pass a call of "typeof()" to the method.
The method could look like this:
public void myDynamicMethod(Type type){
//.....do something with the Type passed in.......
}
|
by: John Arthur |
last post by:
Hi,
I am reading about Reflection.Emit and I can't really imagine a real
situation where I can use this. Can someone give me an example that
can't be done without Reflection or an example of something that If
done with Reflection.Emit will be a lot faster or something sensible.
I will really appreciate your help.
Thanks :
John Arthur
|
by: Eyeawanda Pondicherry |
last post by:
I have put some code together that creates an enum dynamically from some
database values.
The enum can be read perfectly by an application that references the
dynamically generated dll.
If I /emit/ a new version of the assembly, and start the application
again, the new values will appear for the enum.
However, suppose I want the...
| |
by: Gianluca |
last post by:
This is the simplified code I'm trying to generate:
ilg.DeclareLocal(typeof(int)); // define local integer
Label exit = ilg.DefineLabel(); // define "exit" label
ilg.Emit(OpCodes.Ldc_I4_0); // put 0 on the stack
ilg.Emit(OpCodes.Stloc_0); // set the local integer to 0
ilg.Emit(OpCodes.Ldloc_0); // load the local...
|
by: Luis Arvayo |
last post by:
Hi,
In c#, I need to dynamically create types at runtime that will consist of
the following:
- inherits from a given interface
- will have a constructor with an int argument
|
by: John |
last post by:
I am trying to figure out how to translate the following CIL call into
an Emit statement.
In CIL it is:
IL_004c: callvirt instance class System.Data.DataRow
System.Data.DataRowCollection::get_Item(int32)
The C# equivilant is as follows:
MyDataRowCollection;
|
by: joasi |
last post by:
Hi,
I am working in C# with an Object / Relational Database mapping framework, where I want to generate method calls based on string representation of the call signature.
I have used reflection and Method-/Field-/PropertyInfo invokation to do this, but now I want to make the calls faster by using Emit and DynamicMethods
I am now trying to...
|
by: =?Utf-8?B?QXJ0dXJvIE1hcnRpbmV6?= |
last post by:
I've been looking everywhere on how to call AddRange Method of a
List<myClassfield in Reflection.Emit
My code goes like this
MethodInfo method =
typeof(List<>).MakeGenericType(typeof(myClass)).GetMethod("AddRange",
BindingFlags.Instance | BindingFlags.Public, null, new Type {
typeof(IEnumerable<>).MakeGenericType(typeof(myClass)) },...
|
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, well explore What is ONU, What Is Router, ONU & Routers main...
| |
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...
|
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. ...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |