View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000853 | FreeCAD | Feature | public | 2012-10-07 13:13 | 2015-04-27 14:09 |
Reporter | mrlukeparry | Assigned To | yorik | ||
Priority | high | Severity | major | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Fixed in Version | 0.16 | ||||
Summary | 0000853: Unicode Strings in Coin3D | ||||
Description | Implementing UTF support inside FreeCAD and updating all text nodes to utlise this. | ||||
Tags | encoding, unicode | ||||
FreeCAD Information | |||||
|
Actually coin3D can already display non-ascii strings, they must be encoded as latin1: from pivy import coin t = coin.SoText2() sg = Gui.ActiveDocument.ActiveView.getSceneGraph() sg.addChild(t) s = "Alçapão" t.string = s.decode("utf8").encode("latin1") I just adapted the Draft objects that use coin text to do the conversion, maybe it's just a matter of adapting the remaining places where coin text is used. The Document::Annotation object must be adapted to convert text to latin1 when it is given as utf8, I think I can do that, I'll have a look. |
|
As latin-1 can not represent any unicode char. i would recommend to change the error mode from 'strict' to 'replace', 'igonore' or another strategy. t.string = s.decode("utf8").encode("latin1","replace") http://docs.python.org/2/library/codecs.html#codec-base-classes You would not recomment to catch the UnicodeError |
|
Ah good point! Thanks! If anyone know how to do that conversion in c++, I'm all ears! |
|
the problem is that it latin1 encoding will not support non-latin characters. This would be a short term fix for the problem but would be helpful. |
|
Starting from coin 4.0 (libcoin80), utf is apparently totally supported now... This now works: from pivy import coin t = coin.SoText2() sg = Gui.ActiveDocument.ActiveView.getSceneGraph() sg.addChild(t) s = "Alçapão" t.string = s |
|
I believe this can be closed now... Reopen if needed! |
|
i think you forgot the "replace" strategy in the if branch for coin version <4 https://github.com/FreeCAD/FreeCAD_sf_master/commit/32d7839da4413f2be7f34e0d204ab4dfb3d6b034#diff-24e5bcc9ea97d5685e3d0c894b51b1ffR885 |
|
Oops indeed... Seems like I made a little mix of "encode" and "decode"... :) Thanks for checking |
|
Hm but it seems to work fine the way it is... Anybody with coin3 can please test? Thanks... |
|
Coin3: from pivy import coin t = coin.SoText2() sg = Gui.ActiveDocument.ActiveView.getSceneGraph() sg.addChild(t) s = "Alçapão" t.string = s.decode("utf8").encode("latin1") => works from pivy import coin t = coin.SoText2() sg = Gui.ActiveDocument.ActiveView.getSceneGraph() sg.addChild(t) s = "Alçapão" t.string = s => doesn't work from pivy import coin t = coin.SoText2() sg = Gui.ActiveDocument.ActiveView.getSceneGraph() sg.addChild(t) s = "??? / ???" t.string = s => doesn't work Coin4: from pivy import coin t = coin.SoText2() sg = Gui.ActiveDocument.ActiveView.getSceneGraph() sg.addChild(t) s = "Alçapão" t.string = s.decode("utf8").encode("latin1") => doesn't work from pivy import coin t = coin.SoText2() sg = Gui.ActiveDocument.ActiveView.getSceneGraph() sg.addChild(t) s = "Alçapão" t.string = s => works from pivy import coin t = coin.SoText2() sg = Gui.ActiveDocument.ActiveView.getSceneGraph() sg.addChild(t) s = "??? / ???" t.string = s => doesn't work Everything tested on Windows. The Chinese characters are taken from here: http://de.wikipedia.org/wiki/Chinesische_Zeichenkodierung EDIT: The Chinese characters are replaced with "?". |
|
i meant to use only "encode('latin1','replace')" to prevent exceptions like with u'\u2300'.encode('latin1') |
|
Ok, thanks a lot for testing Werner! At least the utf8 / latin1 between coin3 and 4 works OK. I think the chinese texts that don't work are because those characters are not in the default font... @shoogen, ah, thanks!! I didn't remember that "replace" option existed... |
|
I think if we release 0.15 with coin4 on all targets, we could consider this solved. |
|
IMHO we can consider this solved, as all platforms now use coin4... Please reopen if needed |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-10-07 13:13 | mrlukeparry | New Issue | |
2012-10-07 13:13 | mrlukeparry | Status | new => assigned |
2012-10-07 13:13 | mrlukeparry | Assigned To | => mrlukeparry |
2013-08-21 14:10 | yorik | Note Added: 0003501 | |
2013-08-22 04:08 | shoogen | Note Added: 0003503 | |
2013-08-22 11:27 | yorik | Note Added: 0003504 | |
2013-10-25 09:39 | mrlukeparry | Note Added: 0003805 | |
2014-01-08 20:08 | mrlukeparry | Status | assigned => acknowledged |
2014-01-08 20:09 | mrlukeparry | Target Version | 0.14 => |
2014-02-12 12:25 | shoogen | Relationship added | child of 0001404 |
2014-03-29 17:40 | yorik | Note Added: 0004516 | |
2014-05-11 17:45 | yorik | Relationship deleted | child of 0001404 |
2014-05-11 17:45 | yorik | Relationship added | parent of 0001404 |
2014-05-11 17:46 | yorik | Note Added: 0004651 | |
2014-05-11 17:46 | yorik | Status | acknowledged => closed |
2014-05-11 17:46 | yorik | Resolution | open => fixed |
2014-05-11 17:46 | yorik | Fixed in Version | => 0.14 |
2014-05-11 18:07 | shoogen | Assigned To | mrlukeparry => yorik |
2014-05-11 18:07 | shoogen | Note Added: 0004652 | |
2014-05-11 18:07 | shoogen | Status | closed => feedback |
2014-05-11 18:07 | shoogen | Resolution | fixed => reopened |
2014-05-11 18:08 | shoogen | Note Edited: 0004652 | |
2014-05-11 18:22 | yorik | Note Added: 0004653 | |
2014-05-11 19:41 | yorik | Status | feedback => assigned |
2014-05-11 20:00 | yorik | Note Added: 0004655 | |
2014-05-12 13:48 | wmayer | Note Added: 0004660 | |
2014-05-12 13:49 | wmayer | Note Edited: 0004660 | |
2014-05-12 15:53 | shoogen | Note Added: 0004663 | |
2014-05-12 18:06 | yorik | Note Added: 0004665 | |
2014-05-17 15:58 | yorik | Changeset attached | => FreeCAD Master master da4f1bda |
2014-07-06 15:27 | yorik | Target Version | => 0.15 |
2014-09-18 09:56 | shoogen | Relationship added | related to 0001745 |
2014-12-08 14:24 | shoogen | Tag Attached: encoding | |
2014-12-08 14:25 | shoogen | Tag Attached: unicode | |
2015-01-20 23:31 | yorik | Note Added: 0005684 | |
2015-01-20 23:32 | yorik | Fixed in Version | 0.14 => |
2015-01-20 23:32 | yorik | Target Version | 0.15 => |
2015-04-27 14:09 | yorik | Note Added: 0006090 | |
2015-04-27 14:09 | yorik | Status | assigned => closed |
2015-04-27 14:09 | yorik | Resolution | reopened => fixed |
2015-04-27 14:09 | yorik | Fixed in Version | => 0.16 |