Pound sign problem

Steve D'Aprano steve+python at pearwood.info
Tue Apr 11 12:29:09 EDT 2017


On Wed, 12 Apr 2017 01:24 am, Lew Pitcher wrote:

[...]
>>> There is no "pound sign" in ASCII[1]. Try changing your target encoding
>>> to something other than ASCII.
>> 
>> Please don't encourage the use of old legacy encodings.
> 
> I wonder if you actually read my reply.

Of course I did.
 

> What in "Try changing your target encoding to something other than ASCII"
> is encouragement to use "old legacy encodings"?

The fact that "something other than ASCII" includes dozens of old legacy
encodings, including the most obvious one for Western Europeans coming from
a Windows environment: Latin-1.

There are only three practical choices for text: ASCII, Unicode, and legacy
encodings (or "code pages", as many people know them). TRON is effectively
only available in Japan, and even there hardly anyone uses it. (And
besides, Python doesn't support TRON.)

You've (rightly) eliminated ASCII, as the pound sign isn't available. Python
doesn't support TRON, so your instruction to the OP is logically equivalent
to "use Unicode or a legacy encoding". Its the second half of that which I
am objecting to.



>> In 2017, unless you are reading from old legacy files created using a
>> non-Unicode encoding, you should just use UTF-8.
> 
> Thanks for your opinion. My opinion differs.

What would you suggest then, if not UTF-8?

My personal favourite legacy encoding is MacRoman, but I wouldn't recommend
anyone use it except to interoperate with legacy Mac applications and/or
data from the 80s and 90s.

What's your recommendation? "Anything but ASCII"?




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list