Unicode failure

Random832 random832 at fastmail.com
Sun Dec 6 15:36:50 EST 2015


Mark Lawrence <breamoreboy at yahoo.co.uk> writes:
> On 06/12/2015 09:06, Dave Farrance wrote:
>> "D'Arcy J.M. Cain" <darcy at VybeNetworks.com> wrote:
>>> utf-8
>>> Traceback (most recent call last):
>>>   File "./g", line 5, in <module>
>>>     print(u"\N{TRADE MARK SIGN}")
>>> UnicodeEncodeError: 'ascii' codec can't encode character '\u2122' in
>>> position 0: ordinal not in range(128)
>>
>> I *presume* that you're using Linux since you've got a hashbang, so...
>
> Not really a good presumption as the hashbang has been used in Python
> scripts on Windows ever since "PEP 397 -- Python launcher for
> Windows", see https://www.python.org/dev/peps/pep-0397/

However, on windows it would typically be codepage 437, 850, or the
like, and the error message would call it a 'charmap' codec. The 'ascii'
codec error is associated with being in a UNIX environment with an unset
(or "C" or "POSIX") locale.




More information about the Python-list mailing list