Default encoding on script panel


#1

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?


#2

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


#3

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.


#4

What script is causing this ?


#5

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


#6

Remove:

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

Then try again.


#7

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?


#8

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


#9

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

It is fixed now.


#10

@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


#11

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


#12

I really appreciate it, that works excellent.