Andrew Cowper <ju*******@bloat.plus.com> wrote in message news:<87************@bloat.plus.com>...
Anyone come across anything like this before? This is some javascript
validation of user input.
If ch is a question mark character, the test passes and false is
returned.
if ((ch==">") || (ch=="<") || (ch=="\\") ||
(ch=="|") || (ch=="\"") || (ch=="¦")) {
return false;
}
The problem is that the character '¦' is testing as equal to '?'. This
character is Latin 1 A6.
if ("?"=="¦") { alert("Holy Smoke!"); }
It seems to only happen on IE6 (I've tried 6.0.2800.1106).
Anyone got any thoughts?
Thanks
Andrew Cowper
I can't help much, but, yes, I've seen this frequently in cases where
wide to narrow character conversion was involved.
In my quick test (also IE6),
<meta http-equiv='content-type' content='text/html;charset=UTF-8'>
<!-- meta http-equiv='content-type'
content='text/html;charset=ISO-8859-1' -->
<script type='text/javascript'>
function test(){
var b = "?"=="";
alert('b: ' + b);
}
</script>
<a href='#a1' name='a1' id='a1' onclick='test(); return
false;'>test</a>
displays 'true' with UTF-8 but false with ISO-8859-1.
I suppose it's a question of how the == operator code in a given
browser compares a lower ASCII char to a wide char (not sure how many
bytes UTF-8 needs for '¦'). I suppose a conversion of the wide char to
a question mark might be intended to convey 'dunno what to make of
this'.
Not an expert. FWIW.