CSV output incorrect when stimulus is in a right-to-left script
Observed that when a stimulus in a multilingual experiment was in Hebrew, the stimulus and response were swapped in the CSV output (just using .csv() on the DataCollection).
This did not happen when the Hebrew text was wrapped in tags, i.e. it started and ended with left-to-right characters.
Will work up a minimal example to reproduce when I have a moment.
& also test with other right-to-left scripts!
& also test with other right-to-left scripts!
Adding the Unicode LTR order mark, \u200e, to the end of the RTL text fixes this problem. However it seems there is no easy way to detect RTL text -- see https://stackoverflow.com/questions/12006095/javascript-how-to-check-if-character-is-rtl
I'd be reluctant to say that the order mark should just be added at the end of every column of CSV (even though this would technically be correct). Other software may not interpret this correctly, so it could break existing workflows.
As I see it the options are:
- Try to detect if last char of each field will be rendered RTL and insert LTR mark to correct, or apply another solution (such as enclosing in
<span></span>, which seems to work. - Apply one of these solutions to all columns uniformly
- Don't change the code, but note one of these solutions in the jsPsych docs.
Example code here: experiment.zip (zip because GitHub doesn't allow raw HTML upload)