unicode problem
Posted: Fri Mar 21, 2008 2:58 pm
Dear forum,
I wrote a little script a long time ago that created a vocabulary quiz. It was reading an xml-file where the nodes had a "reference language" and a "target language" element. Both of them could contain non-ascii characters (e.g. polish and german). Since I did not have an http server, I was running
and then opened output.html with my browser.
Everything worked fine.
A few months ago, I changed my OS from windows xp to ubuntu. Without making any changes to the code, using the above command something went wrong. Here is a screenshot with the bad output to the left and the good output (generated back then) to the right (the changed color is normal, done by the javascript, so are the different quenstion numbers since they are random)

This is also what I see when I open the html file with gedit. It seems that every special character is replaced by two (!) other special characters (I guess the missing information is that both bytes should be interpreted as one character).
Replacing the special characters with { is not an option, by the way, since I need the javascript to compare the solution input by the student with the one saved in the file.
I would appreciate any help.
The relevant part of the php script is this:
Thank you for your time,
Nikos
I wrote a little script a long time ago that created a vocabulary quiz. It was reading an xml-file where the nodes had a "reference language" and a "target language" element. Both of them could contain non-ascii characters (e.g. polish and german). Since I did not have an http server, I was running
Code: Select all
php quiz.php > output.htmlEverything worked fine.
A few months ago, I changed my OS from windows xp to ubuntu. Without making any changes to the code, using the above command something went wrong. Here is a screenshot with the bad output to the left and the good output (generated back then) to the right (the changed color is normal, done by the javascript, so are the different quenstion numbers since they are random)

This is also what I see when I open the html file with gedit. It seems that every special character is replaced by two (!) other special characters (I guess the missing information is that both bytes should be interpreted as one character).
Replacing the special characters with { is not an option, by the way, since I need the javascript to compare the solution input by the student with the one saved in the file.
I would appreciate any help.
The relevant part of the php script is this:
Code: Select all
$currq = '
<div class="quizelement" id="e%02d">
<table>
<tr><td colspan="2" class="header">Question %d</td></tr>
<tr><td><img src="flags/%s_small.png"/></td>
<td><b>%s</b> - <i>%s</i></td></tr>
<tr><td><img src="flags/%s_small.png"></td>
<td><input size="54" id="a%d" type="text" onChange="checkSolution(this.value,\'%s\',\'%02d\')"></td></tr>
<tr><td></td>
<td align="center"> <span id="s%02d" class="solution"><b>Wrong </b><span class="tip">(solution: <i>%s</i>)</span></span>
<span id="c%02d" class="correct">Correct!</span></td></tr>
</table>
</div><br/>
';
printf($currq, $j, $j, $myquiz->referencelanguage, $currquestion->referenceword, $currquestion->comment, $myquiz->targetlanguage, $j,
$currquestion->targetword, $j, $j, $currquestion->targetword, $j);Nikos