Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] Danish language?

edited June 2014 in OpenSesame

Hi,

I built a questionnaire in Opensesame and it works fine in Dutch and English. Now we would like to send it to a collaborator in Denmark, but I get this error:

Python traceback:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 18: ordinal not in range

Is it not possible to use the Danish letters?

thanks Mona

Comments

  • edited 4:43AM

    Hi Mona,

    Generally speaking, a UnicodeDecodeError occurs when you are working with text that contains special characters (like Danish, which uses accents like 'ø'), but don't explicitly specify your text encoding. OpenSesame should be unicode-safe, but if you write your own inline_script items, you have to take care not to trigger these errors. It can be tricky stuff.

    I would first take a look at the full error message, which you can find in the debug window. This should tell you whether it's triggered by an inline_script (I suspect so), or by OpenSesame itself. If the latter is the case, it's a bug. But either way, please post the full error message and (if any) the inline_script that caused it.

    Is it not possible to use the Danish letters?

    image

    Cheers,
    Sebastiaan

  • edited May 2014

    Hi Sebastiaan,

    thank you for your nice reply :)

    It indeed has to do with the inline script. It works up until I change the name of the questions into Danish.

    In a normal text display it works fine, indeed.

    Mona

    the 'stripped' code that gives the error after including Danish letters:

    for the questions:

    Question_number1 = "Jeg tænkte på andre"
    

    to build the questionnaire:

    from libopensesame import widgets
    form = widgets.form(self.experiment, cols=[2,1], rows=[1,1,1,1,1,1,1,1,1,1,1,1])
    question01 = widgets.label(form, text=Question_number1, center=False)
    form.set_widget(question01, (0,rows[0]))
    form._exec()
    

    to log name of question:

    self.log('Question1 = "Jeg tænkte på andre"')
    

    Python traceback:

    inline_error: Error: Inline script error
    In: inline_10 (run phase)
    File "libopensesame/item.pyc", line 989, in log
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 18: ordinal not in range(128)
    
  • edited 4:43AM

    Hi Mona,

    The problem is the logging part, here:

    self.log('Question1 = "Jeg tænkte på andre"')
    

    You're running into a pretty tricky aspect of Python, which causes a lot of trouble for a lot of people. Basically, if you define a str (e.g., s = 'my str'), Python doesn't know what the character encoding is, and--unless you explicitly tell Python otherwise--assumes that it is ascii, which doesn't contain any special characters. This is weird, because you can see the special characters in the editor, but nevertheless Python doesn't know how to deal with them.

    To work around this in a more-or-less reliable way you should use the unicode type, like so:

    self.log(u'Question1 = "Jeg tænkte på andre"')
    

    The difference in notation is the little u in front of the text, but this makes all the difference. You now declare the text in a non-ambiguous way, i.e. in a such a way that Python knows how to deal with special characters.

    This is a really tricky subject, which is explained reasonably well here:

    But for now, I would simply recommend always using unicode text in inline_script items. As a general (but non-fool-proof) rule this works best.

    Cheers!
    Sebastiaan

  • edited 4:43AM

    Perfect! All that was between me and the solution was a little "u" :) :) :)

    Thank you so much for the great help!

    Now we can send the questionnaire (and open sesame) to Denmark!

    Mona

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games