Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Glyphs as JavaScript variables 1

Status
Not open for further replies.

CliveC

Programmer
Nov 21, 2001
1,222
US
Can anyone figure out why this does not 'seem' to work correctly and what might be done to achieve the desired result?

Code:
<script>
var1=unescape('&#141;')
var2=unescape('&#142;')
var3=unescape('&#143;')
document.writeln("var1="+var1+"<br />")
document.writeln("var2="+var2+"<br />")
document.writeln("var3="+var3+"<br />")

if (var1==var3) {
 document.write('var1=var3? - TRUE <br />')
}else{
 document.write('var1=var3? - FALSE <br />')
}

if (var1==var2){
 document.write('var1=var2? - FALSE <br />')
}else{
 document.write('var1=var2? - TRUE <br />')
}
</script>

Clive
 
Look at the order you put the true/false statements in for each example.

Lee
 
The results you got are accurate since var1 does not equal var2 or var3. Since you didn't specify WHAT you thought the problem was, I noticed the FALSE/TRUE statements in the comparisons were in different orders. Why were you expecting the comparison to come up with opposite results?

Lee
 
Depends on which character set you have your display set to. I got 3 different characters when I copied and pasted your code into a text editor and then ran it. I have IE set for Unicode (UTF-8). You can't test the output of non-ANSI Unicode characters if you don't have your browser set to display them correctly. The answers from your script show that none of the characters are equal to any of the others, even though you have the TRUE/FALSE statements mixed up in your code.

Lee
 
When you see the little square box as a character, that means that the encoding and character set you're using don't have a character written to display for that number code. Just because there are 2 (or more) little square boxes doesn't mean that they're the same character. It just means that whoever designed the font didn't include printable characters for those numbers.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top