Opened 12 years ago

Closed 11 years ago

#6477 closed defect (duplicate)

notebook -- improve UNICODE handling of truncated_name function in

Reported by: was Owned by: boothby
Priority: major Milestone: sage-4.3.1
Component: notebook Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by was)

From NoSyu <>


I use Sagemath to show the Linear Algebra problems solution.

And I am Korean.

Therefore I write the title in Korean.

But in worksheet,  the title is broken because of truncated_name
function in

def truncated_name(self, max=30):
       name =
       if len(name) > max:
           name = name[:max] + ' ...'
       return name

But Unicode is not 1 byte by character.

So Korean is broken if max is midpoint of Korean one character.

Therefore I modify the function code like this.

def truncated_name(self, max=30):
       name = unicode(, "utf-8") # name =
       if len(name) > max:
           name = name[:max] + ' ...'
       return name.encode('utf-8') # return name

Now name is encoded by unicode, then Korean one character's length is
1, not 2 or 3.

So I can see the right title.

I think there are more good choice to solve the problem.
Because I don't know about Python well and unicode also.
So I suggest this.

Change History (2)

comment:1 Changed 12 years ago by was

  • Description modified (diff)

comment:2 Changed 11 years ago by timdumol

  • Report Upstream set to N/A
  • Resolution set to duplicate
  • Status changed from new to closed

I'll mark this as a duplicate since #7249 subsumes this.

Note: See TracTickets for help on using tickets.