Can't use Japanese in the plugin script

Fixed AfterEffects plugin to support Japanese warning messages.

self.AddStdoutHandlerCallback( "WARNING:(After Effects 警告: .*)" ).HandleCallback += self.HandleStdoutWarning #Japanese

But when I run it I get an error.

SyntaxError : ("(unicode error) 'utf-8' codec can't decode byte 0x8c in position 23: invalid start byte", ('C:\\ProgramData\\Thinkbox\\Deadline10\\workers\\foo\\plugins\\foo\\AfterEffects.py', 123, 39, '        self.AddStdoutHandlerCallback( "WARNING:(After Effects 警告: .*)" ).HandleCallback += self.HandleStdoutWarning #Japanese\n'))

The environment is Python3 and the file is encoded in UTF-8, with no encoding definition. (It is Python3, so it should be UTF-8.)

After trying various things, I found the following.

  • Encode the file in sjis(cp932).
  • Encoding definition is set to cp932.

Now it works correctly, but why is it not processed in UTF-8?
I don’t know if this is a bug or normal behavior.

Is it necessary to define sjis(cp932) in Japanese environment?

Hello @kazuma

Thanks for sharing the fix. I don’t know either, maybe someone with more knowledge here can comment on this. This post might help understanding.

@zainali
Thank you for information.
I can now use Japanese in the code, but when I try to set it in the UI (Label), the characters are garbled.
I checked the font settings of PyQt5, but it was a font that can handle Japanese.
Hmm, what should I do?

Can you share like a screen shot or log where and also share what you expect to see.

There may be someone who might have run into same issue.

It’s a sample.

JapaneseUiCase1.py (363 Bytes)

# coding: UTF-8

from DeadlineUI.Controls.Scripting.DeadlineScriptDialog import DeadlineScriptDialog

def __main__():
    scriptDialog = DeadlineScriptDialog()
    scriptDialog.SetTitle( "日本語UI" )
    scriptDialog.SetSize( 300, 200 )
    scriptDialog.AddControl( "Label", "LabelControl", "日本語ラベル" )
    scriptDialog.ShowDialog( True )

JapaneseUiCase2.py (354 Bytes)

# coding: cp932

from DeadlineUI.Controls.Scripting.DeadlineScriptDialog import DeadlineScriptDialog

def __main__():
    scriptDialog = DeadlineScriptDialog()
    scriptDialog.SetTitle( "日本語UI" )
    scriptDialog.SetSize( 300, 200 )
    scriptDialog.AddControl( "Label", "LabelControl", "日本語ラベル" )
    scriptDialog.ShowDialog( True )

I’m running on Windows10.

<DeadlineRepository>/custom/scripts/General/JapaneseUiCase1.py
<DeadlineRepository>/custom/scripts/General/JapaneseUiCase2.py

“JapaneseUiCase1.py” cannot be executed due to a character code error.

Running script JapaneseUiCase1 (<DeadlineRepository>\custom\scripts\General\JapaneseUiCase1.py)
Traceback (most recent call last):
  File "C:\thinkbox-conda\conda-bld\deadline_1669152207333\work\DeadlineProject\DeadlineUI\Commands\ScriptCommands.py", line 105, in InnerExecute
FranticX.Scripting.PythonNetException: SyntaxError : ("(unicode error) 'utf-8' codec can't decode byte 0x93 in position 0: invalid start byte", ('<DeadlineRepository>\\custom\\scripts\\General\\JapaneseUiCase1.py', 7, 27, '    scriptDialog.SetTitle( "日本語UI" )\n'))
   at Python.Runtime.Runtime.CheckExceptionOccurred()
   at Python.Runtime.PythonEngine.ModuleFromString(String name, String code, String fileName)
   at FranticX.Scripting.PythonNetScriptEngine.ExecuteFile(String scriptFile, String moduleName, Boolean optimizeCode)

“JapaneseUiCase2.py” can be executed, but the UI is garbled.
image

The font uses “MS UI Gothic”.
*The settings have not been changed.