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

Pyjamas Desktop unicode support #365

Open
pyjsorg opened this Issue Apr 27, 2012 · 4 comments

Comments

Projects
None yet
1 participant
@pyjsorg
Contributor

pyjsorg commented Apr 27, 2012

What steps will reproduce the problem?

  1. Put a label with unicode characters (e.g. u'š')
  2. Run it in pyjd

What is the expected output? What do you see instead?
Expected (PyJS): http://www.shrani.si/f/3P/YC/4fyR7JiO/loginsibrowser.png
False (PyJD): http://www.shrani.si/f/Z/AX/4DOx1J4/loginsipyjd.png

Full evaluation of code execution can not be done when using unicode code
table. Every unicode character is shown as two characters in PyJD and not
converted to proper characters ('š' instead of 'š') but everything in
widgets is converted to unicode when sent back to server (four characters
for each falsely presented character instead of two).

What version of Pyjamas are you using? which svn revision number?
On what operating system?
0.7pre1 on WinXP

Original issue: http://code.google.com/p/pyjamas/issues/detail?id=354 (January 08, 2010 07:26:42)

@pyjsorg

This comment has been minimized.

Show comment
Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From luke.lei...@gmail.com on January 14, 2010 15:47:48:
davorin, hi,

please can you create a complete test case which demonstrates the problem, where
anyone downloading it need not spend several hours replicating the problem.

attach it as a .tgz archive to this bugreport.

thanks.

l.

Contributor

pyjsorg commented Apr 27, 2012

From luke.lei...@gmail.com on January 14, 2010 15:47:48:
davorin, hi,

please can you create a complete test case which demonstrates the problem, where
anyone downloading it need not spend several hours replicating the problem.

attach it as a .tgz archive to this bugreport.

thanks.

l.

@pyjsorg

This comment has been minimized.

Show comment
Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From davorin....@gmail.com on January 15, 2010 13:58:36:
While preparing test case I found one str conversion too much in framework (setting
values for HTML widget).
The same case is with TextBox (TextBoxBase):
def setText(self, text):
DOM.setAttribute(self.getElement(), "value", str(text))

Certainly there is problem with 'str' conversion. Should it be 'unicode' conversion
by default or should it depend on text variable data type? Anyway unicode data type
is not supported in PyJS yet (Issue 234 / TODO).

Contributor

pyjsorg commented Apr 27, 2012

From davorin....@gmail.com on January 15, 2010 13:58:36:
While preparing test case I found one str conversion too much in framework (setting
values for HTML widget).
The same case is with TextBox (TextBoxBase):
def setText(self, text):
DOM.setAttribute(self.getElement(), "value", str(text))

Certainly there is problem with 'str' conversion. Should it be 'unicode' conversion
by default or should it depend on text variable data type? Anyway unicode data type
is not supported in PyJS yet (Issue 234 / TODO).

@pyjsorg

This comment has been minimized.

Show comment
Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From davorin....@gmail.com on January 18, 2010 13:44:31:
Another issue on same theme: TabPanel does not accept unicode for tabText.

Problem is in TabBar.insertTab where unicode is taken as widget:
if isinstance(text, str):
if asHTML:
item = HTML(text)
else:
item = Label(text)
item.setWordWrap(False)
else:
# passing in a widget, it's expected to have its own style
item = text

Possible solution for last revision is attached. It also contains workaround for
PyJS, because 'isinstance' fails on nonobject data against tuple of objects.
Example:
isinstance("A", (str, int, long))
isinstance(12, (str, int, long))

Reason (pyjslib.py 2372 isinstance R5506-7):
if (typeof object_ != 'object' && typeof object_ != 'function') {
return false;

Contributor

pyjsorg commented Apr 27, 2012

From davorin....@gmail.com on January 18, 2010 13:44:31:
Another issue on same theme: TabPanel does not accept unicode for tabText.

Problem is in TabBar.insertTab where unicode is taken as widget:
if isinstance(text, str):
if asHTML:
item = HTML(text)
else:
item = Label(text)
item.setWordWrap(False)
else:
# passing in a widget, it's expected to have its own style
item = text

Possible solution for last revision is attached. It also contains workaround for
PyJS, because 'isinstance' fails on nonobject data against tuple of objects.
Example:
isinstance("A", (str, int, long))
isinstance(12, (str, int, long))

Reason (pyjslib.py 2372 isinstance R5506-7):
if (typeof object_ != 'object' && typeof object_ != 'function') {
return false;

@pyjsorg

This comment has been minimized.

Show comment
Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From davorin....@gmail.com on May 07, 2010 13:36:10:
I noticed this has been used for r2388. Attachment is solution for the same problem
in another module.

Real problem persists in pyjs/src/pyjs/pyjslib.py isinstance function as stated in
previous example (value against tuple of objects - the last if in JS part returns
false before python part checks for tuple).

Contributor

pyjsorg commented Apr 27, 2012

From davorin....@gmail.com on May 07, 2010 13:36:10:
I noticed this has been used for r2388. Attachment is solution for the same problem
in another module.

Real problem persists in pyjs/src/pyjs/pyjslib.py isinstance function as stated in
previous example (value against tuple of objects - the last if in JS part returns
false before python part checks for tuple).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment