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


Groups > comp.lang.javascript > #28829

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

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: string comparison fails? - Image1.jpg (0/1)
Date Sat, 17 Oct 2015 11:18:35 +0100
Organization A noiseless patient Spider
Lines 36
Message-ID <87io65pzlw.fsf@bsb.me.uk> (permalink)
References <08642bl9537lanf90ghcng1hefvuejcl20@4ax.com>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="16688"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+LrThtZeS2lCLmm1kwh52bcu1jEu3zXQE="
Cancel-Lock sha1:0dCA7Zfcqe+3MNYD9iq2OJx8bIk= sha1:d0vCjGc4p5OJBSbC4Ztxy3jAoCA=
X-BSB-Auth 1.9e6d24684c86ba57c79a.20151017111835BST.87io65pzlw.fsf@bsb.me.uk
Xref csiph.com comp.lang.javascript:28829

Show key headers only | View raw


joe <mt@invalid.com> writes:

> 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")

There's a big clue here.  How can a 4 character string ever equal "TTY"?

<snip>
> 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>

Almost every ">" is follwoed by a newline character.  I'm guessing that
what looks to you like "TTY" is, in fact "\nTTY" (and hence 4 characters
long).

-- 
Ben.

Back to comp.lang.javascript | Previous | Next — Previous in thread | 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