Scripting, strings and diacritics

RoboFont Forums Bugs Scripting, strings and diacritics

This topic contains 4 replies, has 3 voices, and was last updated by  joanca 8 years, 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #4192

    joanca
    Participant

    I type this code in a script window:

    Firsts = “F P T V”
    Seconds = “à é ï ø û”
    nalts = 10

    for f in Firsts.split(” “):
    for s in Seconds.split(” “):
    print “%s%s ” %(f, s) *nalts

    It runs and it works fine (print the expected output). When I try to save the script or RF crashes or I get this traceback:
    “””
    Traceback (most recent call last):
    File “Combinations RF.py”, line 10, in
    AttributeError: ‘NoneType’ object has no attribute ‘selection’
    Traceback (most recent call last):
    File “lib/scripting/pyDocument.pyc”, line 37, in writeSafelyToURL_ofType_forSaveOperation_error_
    UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xe0′ in position 106: ordinal not in range(128)
    Traceback (most recent call last):
    File “lib/doodleDelegate.pyc”, line 81, in sendEvent_
    File “lib/scripting/pyDocument.pyc”, line 37, in writeSafelyToURL_ofType_forSaveOperation_error_
    UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xe0′ in position 106: ordinal not in range(128)
    “””

    I guess it has to do with “à é ï ø û”.
    When I save the code in Textmate, “à é ï ø û” get changed in the script for “à é ï ø û”.

    I even tried using “# -*- coding: utf-8 -*-” as first line of code but didn’t work.
    Might it be a Python bug? I’ve been trying to deal with this for a while and it’s a headache.

    BTW, is there a way of getting “à” as output from “agrave”?
    In some way RF does it in the Space Center window.

    Thanks as always,

    Jca

    #4195

    jo
    Participant

    I hope somebody will post a more elaborate answer but I think you should convert the non ascii characters so python can read them.

    Seconds = u”\u00E0 \u00E9 \u00EF \u00F8 \u00FB”

    #4198

    joanca
    Participant

    Thanks jo! with this info I’ll manage I guess.
    At this point something that just works it’s perfect, the dark magic in the insides is not important now. I’ll check later.

    #4200

    frederik
    Keymaster

    This is idd a bug :) and already solved in the beta and will be fixed in the next release.

    #4201

    joanca
    Participant

    dank u Frederik

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.