#6477: notebook -- improve UNICODE handling of truncated_name function in
worksheet.py
----------------------+-----------------------------------------------------
Reporter: was | Owner: boothby
Type: defect | Status: new
Priority: major | Milestone: sage-4.1.1
Component: notebook | Keywords:
Reviewer: | Author:
Merged: |
----------------------+-----------------------------------------------------
Description changed by was:
Old description:
> {{{
> 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.
> }}}
New description:
{{{
From NoSyu <[email protected]>
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.
}}}
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6477#comment:1>
Sage <http://sagemath.org/>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---