Default encoding on script panel

Hi,

This syntax was acceptable on (1226) and before version.

# -*- coding: utf-8 -*-*
print u'あお'

But it causes UnicodeEncodeError: on version (1227). And I have to specify .encode("utf-8") after the string or remove “u” on the top to fix that.

I could not see a description about that in (1227) release note, is this change intensional update?

I have change a bit doubt this. I made it work without the coding and u prefix. Now it works in both cases.

Thank you so much for your quick response.
I checked that on version 1228 and 1229, both versions could show up unicode characters correctly, however UnicodeEncodeError: happens after that.

What script is causing this ?

That’s my macro panel when this script is executed.

Remove:

  • line 2 (the one containing coding)
  • the u in front of the string

Then try again.

Yes, I know, removing “u” prefix, or adding “.encode(“utf-8”)” in the end string, then the error will be fixed.

There are many lines which have ‘u’ prefix string with print to stdout to MacroPanel in my handmade scripts. The line causes an interruption of process after updating the latest version.

So, I would like to know how to fix them. DoI need to find out all of error lines and fix everything?

In the Macro Panel, press Cmd-Shift-F, search for u" and replace it with " and you should be good.

I have worked on this and it should work. But again it doesn’t. I’ll have a look.

It is fixed now.

@GeorgSeifert Thanks so much.
@mekkablue I do not believe this is complete idea. We can not clarify the error lines by searching u". e.g. if the glyph is not ascii character, this script causes the error too.

tg = Glyphs.font.selectedLayers[0].parent
print tg.string

This works in version 1230 (that went live a minute ago).

1 Like

I really appreciate it, that works excellent.