Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] unicode and Perl- how to pass command line unicodearguments



Stephen J. Turnbull wrote:
>>>>>>"Ian" == Ian Wells <ijw@example.com> writes:
> 
> 
>     Ian> Thr reason I was being argumentative with Steve and Python is
>     Ian> that while I can see that Python has the same problem with
>     Ian> source code encoding, from what he's saying it seems to take
>     Ian> the approach that the encoding is set string by string,
>     Ian> rather than setting for the whole (or remainder of) the file.
>     Ian> Is that what you meant, Steve?
> 
> No.  In Python 2.x, there is a natural language text object, which for
> historical reasons is called "Unicode" and whose literals are denoted
> u"string".  Then there is raw memory, which for historical reasons is
> called "string" and whose literals are denoted "string".  For
> historical reasons, the raw memory object has continued to be heavily
> abused as a container of natural language text.  What I don't like
> about Perl, as I understand your description, is that Perl mandates
> that abuse (whatever happened to "there's always more than one way to
> do it"? :-)
> 
> As Gabor pointed out, there is a flexible way of making Python as
> DWIM-witted as Perl.  You can set the encoding for the file in the way
> which has become common for many text editors (include Emacsen and
> IIRC vim), by putting a specially-formatted comment (aka coding
> cookie) at the top of the file.

just to avoid any misunderstandings:

this coding-cookie only affect the way python treats the unicode text 
written IN THE GIVEN SOURCE FILE. using something like:

#!/usr/bin/python
# -*- coding: utf-8 -*-

does not mean that all the automatic bytestring=>unicode (and back) 
conversions will use utf-8. the default charset will still be ascii.

gabor


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links