[Solved] Ascii character in material name

A forum to discuss the implementation of a good Materials system in FreeCAD
schupin
Posts: 205
Joined: Sun Jan 21, 2018 1:43 pm

[Solved] Ascii character in material name

Postby schupin » Tue Nov 13, 2018 10:10 pm

Hi,

I find a little bug in the material editor while naming a material with a special character (é)

Code: Select all

Traceback (most recent call last):
  File "/Applications/FreeCAD.app/Contents/Mod/Material/MaterialEditor.py", line 336, in savefile
    name = str(self.widget.Editor.findItems(translate("Material", "Name"), QtCore.Qt.MatchRecursive, 0)[0].text(1))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 4: ordinal not in range(128)
I guess there is a unicode(txt).encode('UTF8') to write somewhere ?

Or inserting

Code: Select all

import sys
reload(sys)
sys.setdefaultencoding('utf8')
at the begining of the file ?
Last edited by schupin on Sat Nov 24, 2018 4:22 pm, edited 1 time in total.
User avatar
yorik
Site Admin
Posts: 10256
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Ascii character in material name

Postby yorik » Thu Nov 22, 2018 1:45 pm

This should now be fixed in git commit 652e1dbdd
schupin
Posts: 205
Joined: Sun Jan 21, 2018 1:43 pm

Re: Ascii character in material name

Postby schupin » Thu Nov 22, 2018 9:53 pm

Works nice.
Thanks !
User avatar
Kunda1
Posts: 3361
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ascii character in material name

Postby Kunda1 » Sat Nov 24, 2018 2:45 pm

Please mark this topic [Solved]
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features