Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notebook -- improve UNICODE handling of truncated_name function in worksheet.py #6477

Closed
williamstein opened this issue Jul 8, 2009 · 2 comments

Comments

@williamstein
Copy link
Contributor

From NoSyu <dongdm@gmail.com>

Hello.

I use Sagemath to show the Linear Algebra problems solution.

And I am Korean.

Therefore I write the title in Korean.

http://nosyu.pe.kr/attach/1/5682987737.png

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


def truncated_name(self, max=30):
       name = self.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(self.name(), "utf-8") # name = self.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.

Component: notebook

Issue created by migration from https://trac.sagemath.org/ticket/6477

@williamstein

This comment has been minimized.

@TimDumol
Copy link
Mannequin

TimDumol mannequin commented Jan 19, 2010

comment:2

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

@TimDumol TimDumol mannequin added r: duplicate and removed p: major / 3 labels Jan 19, 2010
@TimDumol TimDumol mannequin closed this as completed Jan 19, 2010
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants