Mailing List Archive
tlug.jp Mailing List tlug archive tlug 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
- Date: Tue, 14 Feb 2006 23:37:02 +0900
- From: "Stephen J. Turnbull" <stephen@example.com>
- Subject: Re: [tlug] unicode and Perl- how to pass command line unicodearguments
- References: <43EFF8C4.4050704@example.com><87d5hrix3v.fsf@example.com><43F0D507.7020303@example.com><87d5hqhcxe.fsf@example.com><43F1BC35.7060301@example.com>
- Organization: The XEmacs Project
- User-agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.5-b23 (daikon, linux)
>>>>> "gabor" == gabor <G> writes: gabor> could you explain this part to me? why is your own gabor> source-code unreliable? :) Because *my* source code is all *open source*, and it is *intended* that people other than me use it. Who knows what they might do? Consider iconv -f utf-8 -t shift_jis oh-wow-colors.py \ | mail -s "way cool!" i-use-becky@example.com I've seen this kind of thing altogether too often (not just Japanese, Russians have a fondness for encoding proliferation, too). And you know what happens if you *edit* such a file with a cookie-aware editor! gabor> for example, this works fine: gabor> ======= gabor> #!/usr/bin/python gabor> # -*- coding: utf-8 -*- gabor> gabor> text = u"これは日本語です" gabor> print len(text) gabor> ======== And for this ======= #!/usr/bin/python # -*- coding: utf-8 -*- text = u"これは日本語です" print text ======== the output is Traceback (most recent call last): File "./junk.py", line 5, in ? print text UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-7: ordinal not in range(128) Not what we want to see, but that is _precisely_ the right answer here, since you cannot know what encoding the stream being print'ed to accepts. You could say "well, at least the cookie saves you from typing ".encode('utf-8')" after every literal," but that may or may not really be very helpful to someone not as familiar with Python's Unicode facilities as you or I. "Explicit is better than implicit."<wink> -- School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN Ask not how you can "do" free software business; ask what your business can "do for" free software.
- References:
- Re: [tlug] unicode and Perl- how to pass command line unicodearguments
- From: David Riggs
- Re: [tlug] unicode and Perl- how to pass command line unicodearguments
- From: Stephen J. Turnbull
- Re: [tlug] unicode and Perl- how to pass command line unicodearguments
- From: gabor
- Re: [tlug] unicode and Perl- how to pass command line unicodearguments
- From: Stephen J. Turnbull
- Re: [tlug] unicode and Perl- how to pass command line unicodearguments
- From: =?UTF-8?B?R8OhYm9yIEZhcmthcw==?=
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Videodev problem
- Next by Date: Re: [tlug] unable to create local copy utf8 encoded Japanese MySQLdata
- Previous by thread: Re: [tlug] unicode and Perl- how to pass command line unicodearguments
- Next by thread: Re: [tlug] unicode and Perl- how to pass command line unicodearguments
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links