Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
Maya Forum
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

french accent marks

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
606 Views, 3 Replies

french accent marks

Hi all,

following problem:

import maya.cmds as cmds

#    Create a window with a some fields for entering text.
#
window = cmds.window()
cmds.rowColumnLayout( numberOfColumns=2, columnAttach=(1, 'right', 0), columnWidth=[(1, 100), (2, 250)] )
cmds.text( label='Name' )
txt = "mais le premier de ces indigènes qui mit la main sur la rampe de l' escalier rejeté en arrière par je ne sais quelle force invisible s' enfuit poussant des cris affreux et faisant des gambades exorbitantes"
name = cmds.textField(tx = txt)
cmds.showWindow( window )

output_str = cmds.textField(name, q=True, tx=True)

how do i encode/decode the "output_str"?, because every approach failed inside maya.

thx

3 REPLIES 3
Message 2 of 4
zewt
in reply to: Anonymous

The problem isn't Python here, it's a bug in Maya's script editor.  It lets you enter Unicode, but it converts it to the Windows ANSI codepage before executing it, instead of to UTF-8.  Your system doesn't have those characters, so they get substituted.  You can see the problem by just running 

 

print "è"

 

and it'll just print "e", depending on your OS language.

 

Just write your script in a file instead of the script editor (prefixing "-*- coding: utf-8 -*-" if needed) and import it, so your code isn't going through the script editor.  It's safer that way anyway, I've lost a *lot* of scripts over the years to Maya crashing because I got lazy and prototyped too much in the script editor...

 

Message 3 of 4
Anonymous
in reply to: zewt

Thank you for your answer, I did not suspect that it is due to python. I assume this problem is related to Qt and not script editor itself, because the encoding failed in every layout inside maya. I do not necessarily have to show the content within maya, but how would the solution look like if I have to. Will the problem be solved if I install the French Maya version?

 

Message 4 of 4
zewt
in reply to: Anonymous

Qt handles it just fine, it's caused by the script editor's edit box (other editors probably do the same thing, like the script panel and script editor).  If you run it from a file instead of through the script editor, the text works fine.

 

It should also work if your Windows language is set to French (or any language that supports those characters), but I can't test this easily.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report