Sage chokes on German umlauts

17 views
Skip to first unread message

Lars Fischer

unread,
Mar 18, 2008, 5:00:08 PM3/18/08
to sage-support
Hello,

this question is related to the thread "SAGE chokes on French
character":
http://groups.google.com/group/sage-support/browse_thread/thread/af850956c4ed137f/34a34d6cf23c4d89?lnk=gst&q=encoding#34a34d6cf23c4d89
two weeks ago. As I understand it, there is a patch which works only
for the notebook.

I want to use umlauts or more general utf-8 encoded files attached to
a sage session in a console. (In Python I would use
# -*- encoding: utf-8 -*-
as second line magic encoding hint, but the preparser prepends its
three line "This file was *autogenerated.... comment and destroys the
encoding hint mechanism .)

If I delete the preparser comment, so that the encoding line becomes
the second line, then python and sage print the umlaut and the error
"Non-ASCII character '\xc3' in file .... " does not occur.

So my questions are:
-how can I use utf-encoded files and attach them to a sage console (I
am not using the notebook).
-what encoding does sage use?(Setting it to a unicode encoding, would
probably break everything?)

The thread above mentions codecs.open('stuff.txt','wb','utf-8'), can I
use a line like this, to set the encoding of the running sage console
to something different. Perhaps in a user-configuration file?

Thanks in advance,
Lars Fischer

Martin Albrecht

unread,
Mar 19, 2008, 7:41:09 AM3/19/08
to sage-s...@googlegroups.com
I consider this a bug.

It is now tracked at:

http://trac.sagemath.org/sage_trac/ticket/2593

and a patch that fixes the issue is available.

~$ cat test.sage


# -*- encoding: utf-8 -*-
"""

Gröbner bases are übercool.
"""

def gb(I):
return I.groebner_basis()

~$ sage
----------------------------------------------------------------------
| SAGE Version 2.10.4, Release Date: 2008-03-17 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
Loading SAGE library. Current Mercurial branch is: smallroots
sage: attach "test.sage"
sage: P.<x,y,z> = PolynomialRing(QQ)
sage: I = sage.rings.ideal.Katsura(P)
sage: gb(I)
[x + 2*y + 2*z - 1, y*z + 6/5*z^2 - 1/10*y - 2/5*z, y^2 - 3/5*z^2 - 1/5*y +
1/5*z, z^3 - 79/210*z^2 + 1/30*y + 1/70*z]

Cheers,
Martin

--
name: Martin Albrecht
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_www: http://www.informatik.uni-bremen.de/~malb
_jab: martinr...@jabber.ccc.de

Reply all
Reply to author
Forward
0 new messages