Ask Your Question
0

unicode coding

asked 2019-12-19 10:35:23 +0100

Jingenbl gravatar image

updated 2019-12-23 16:35:39 +0100

Iguananaut gravatar image

# -*- coding = UTF-8 -*-

does not work ?

Big thanks

edit retag flag offensive close merge delete

Comments

1

try

# -*- coding: utf-8 -*-
David Coudert gravatar imageDavid Coudert ( 2019-12-20 09:37:43 +0100 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2019-12-23 16:41:54 +0100

Iguananaut gravatar image

updated 2019-12-23 16:44:04 +0100

Since you cited PEP-263, read carefully the regular expression it gives for what the coding line should match:

^[ \t\f]*#.*?coding[:=][ \t]*([-_.a-zA-Z0-9]+)

specifically, the string coding should be immediately followed by a : or =, no whitespace. The encoding name UTF-8 is fine since encoding names are not case-sensitive.

The most common way to write this is:

# -*- coding: utf-8 -*-

Note: Since this is just a standard Python feature it is not specific to Sage, so you could also likely find answers to your problem on StackOverflow or any other source for Python help.

edit flag offensive delete link more

Comments

You are absolutely right ... but it does not work better, while in Python 3 it works very well Big thangs

Jingenbl gravatar imageJingenbl ( 2019-12-23 16:53:36 +0100 )edit

In what way does it "not work" for you? I just tested in this on Sage 8.9 with Python 2.7 on Windows and it works as expected. On Python 3 it's not necessary because all files are treated as UTF-8 encoded by default unless specified otherwise.

Iguananaut gravatar imageIguananaut ( 2019-12-23 16:56:46 +0100 )edit
0

answered 2019-12-20 09:36:26 +0100

Emmanuel Charpentier gravatar image

See PEP263. Note that UTF-8 does not appear in the standard encodings list. So maybe try # -- coding = utf_8 -- (lowercase, underscore).

The imminent Python 3-based Sage 9 should solve the problem..

edit flag offensive delete link more

Comments

sorry but utf-8, utf_8, UTF-8 ou UTF_8 does not work on windows... (# -- coding= -- on the first line) something else to had?

big thanks

Jingenbl gravatar imageJingenbl ( 2019-12-20 10:49:42 +0100 )edit

have you tried using -*- instead of -- ?

David Coudert gravatar imageDavid Coudert ( 2019-12-20 12:21:21 +0100 )edit

not better unfortunately

Jingenbl gravatar imageJingenbl ( 2019-12-20 15:35:49 +0100 )edit
Iguananaut gravatar imageIguananaut ( 2019-12-23 16:42:55 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-12-19 10:35:23 +0100

Seen: 379 times

Last updated: Dec 23 '19