Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #28827

string comparison fails? - Image1.jpg (0/1)

From joe <mt@invalid.com>
Newsgroups comp.lang.javascript
Subject string comparison fails? - Image1.jpg (0/1)
Message-ID <08642bl9537lanf90ghcng1hefvuejcl20@4ax.com> (permalink)
Date 2015-10-17 13:00 +0300
Organization Elisa Customer

Show all headers | View raw


In my javascript I use XMLHttpRequest to get an htm file into text memory
(varaibale "all") and them split the text into an array with following code:

...
            var apu2=all.split(">");
            var ii=apu2.length;
            for (i=0;i<ii;i++)
               {
               allte=apu2[i].substring(0,4);
               if (allte=="TTY")
                  {
...

I then have apu2 as:
apu2[0]  "-><!DOCTYPE.."
apu2[1]  "<HTML"
..
apu2[8]  "TTYAhelpc.htm"
..

(I've include a small jpg to illustrate it)

When cycling through the string and "allte" variable gets "TTY" the comparison 
if (allte=="TTY")
fails allthough I can clearly see in debugger that is has "TTY" (see my jpg
image).

What I am doing wrong? I tried everything I could think of.

The local file I'me reading into "all" and then splitting into array at ">" is:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<BODY>
TTY:helpc.htm
</body>
</html>

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

string comparison fails? - Image1.jpg (0/1) joe <mt@invalid.com> - 2015-10-17 13:00 +0300
  Re: string comparison fails? - Image1.jpg (0/1) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-17 11:18 +0100
    Re: string comparison fails? - Image1.jpg (0/1) joe <mt@invalid.com> - 2015-10-17 13:57 +0300
    Re: string comparison fails? - Image1.jpg (0/1) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-10-17 14:59 +0200
      Re: string comparison fails? - Image1.jpg (0/1) Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-17 14:37 +0100
        Re: string comparison fails? - Image1.jpg (0/1) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-10-17 16:11 +0200
  Re: string comparison fails? - Image1.jpg (0/1) "danca (Daniele Campagna)" <cyberdanny@tiscalinet.it> - 2015-10-17 12:21 +0200
  Re: string comparison fails? - Image1.jpg (0/1) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-10-17 12:28 +0200

csiph-web