Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Tokenizer does not like ampersand

Reply
Thread Tools

Tokenizer does not like ampersand

 
 
keepyourstupidspam@yahoo.co.uk
Guest
Posts: n/a
 
      08-25-2006
Hi,

I am passing a string to my tokenize function, if the string contains
an ampersand character only the string as far as the & character gets
inputted to the function.

these parameters work fine

name;address1;address2;addres3

these break it

name;address1;add & rest;addres3

the semi colon is the delimiter used in the tokenize function.

the string parameter to the tokenize function in the good instance is
this

inString="name;address1;address2;addres3";

in the instance containing the & it is:

inString="name;address1;add ";


Anyone know why the & character terminates the string? This results in
the tokenize function not receiving the full string.

Thanks and appreciate your help.
Enda

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      08-25-2006
wrote:
> I am passing a string to my tokenize function, if the string contains
> an ampersand character only the string as far as the & character gets
> inputted to the function.
>
> these parameters work fine
>
> name;address1;address2;addres3
>
> these break it
>
> name;address1;add & rest;addres3
>
> the semi colon is the delimiter used in the tokenize function.
>
> the string parameter to the tokenize function in the good instance is
> this
>
> inString="name;address1;address2;addres3";
>
> in the instance containing the & it is:
>
> inString="name;address1;add ";
>
>
> Anyone know why the & character terminates the string? This results in
> the tokenize function not receiving the full string.


The error is in your tokenize function, on line 42. See FAQ 5.8.

There is one other thing I thought I'd mention: your strings also differ
in the presence of *spaces*.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
 
keepyourstupidspam@yahoo.co.uk
Guest
Posts: n/a
 
      08-25-2006

Victor Bazarov wrote:
> wrote:
> > I am passing a string to my tokenize function, if the string contains
> > an ampersand character only the string as far as the & character gets
> > inputted to the function.
> >
> > these parameters work fine
> >
> > name;address1;address2;addres3
> >
> > these break it
> >
> > name;address1;add & rest;addres3
> >
> > the semi colon is the delimiter used in the tokenize function.
> >
> > the string parameter to the tokenize function in the good instance is
> > this
> >
> > inString="name;address1;address2;addres3";
> >
> > in the instance containing the & it is:
> >
> > inString="name;address1;add ";
> >
> >
> > Anyone know why the & character terminates the string? This results in
> > the tokenize function not receiving the full string.

>
> The error is in your tokenize function, on line 42. See FAQ 5.8.
>
> There is one other thing I thought I'd mention: your strings also differ
> in the presence of *spaces*.
>
> V
> --
> Please remove capital 'A's when replying by e-mail
> I do not respond to top-posted replies, please don't ask



Hi,


How could the problem be in the tokenize function as the string
paramerer to this function is already broken by the & character


name;address1;address2;addres3
results in
inString="name;address1;address2;addres3";

name;address1;add & rest;addres3
results in
inString="name;address1;add ";


How do you know what line is giving a problem in my tokenize function?

Can anyone help me here.

Thanks.
Enda

 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      08-25-2006
wrote:
> [..]
> How could the problem be in the tokenize function as the string
> paramerer to this function is already broken by the & character


It's not broken by the & character. It's most likely broken by the
space.

> name;address1;address2;addres3
> results in
> inString="name;address1;address2;addres3";
>
> name;address1;add & rest;addres3
> results in
> inString="name;address1;add ";
>
>
> How do you know what line is giving a problem in my tokenize function?


I have a crystal ball.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
Bo Persson
Guest
Posts: n/a
 
      08-25-2006

<> skrev i meddelandet
news: oups.com...
>
> Victor Bazarov wrote:
>>
>> The error is in your tokenize function, on line 42. See FAQ 5.8.
>>


>
> How could the problem be in the tokenize function as the string
> paramerer to this function is already broken by the & character
>


It is a joke, sort of.

You asked what is wrong with the tokenize function, but you don't show
us any of the code. So Victor guessed that it might be on line 42. (Or
it might be somewhere else. We don't know.)


Bo Persson


 
Reply With Quote
 
keepyourstupidspam@yahoo.co.uk
Guest
Posts: n/a
 
      08-25-2006

Bo Persson wrote:
> <> skrev i meddelandet
> news: oups.com...
> >
> > Victor Bazarov wrote:
> >>
> >> The error is in your tokenize function, on line 42. See FAQ 5.8.
> >>

>
> >
> > How could the problem be in the tokenize function as the string
> > paramerer to this function is already broken by the & character
> >

>
> It is a joke, sort of.
>
> You asked what is wrong with the tokenize function, but you don't show
> us any of the code. So Victor guessed that it might be on line 42. (Or
> it might be somewhere else. We don't know.)
>
>
> Bo Persson



Dudes.

Still broken even when no spaces in the input string.

name;address1;address2;addres3
results in
inString="name;address1;address2;addres3";


name;address1;add&rest;addres3 <<--- look no spaces
results in
inString="name;address1;add ";


I didn't think the tokenize code was necessary as the problem arrises
before the call to the tokenize function. The problem is the string
escapes at the & character. Why?


A little more background: the string is a parameter to an exe.

configman.exe -list name;address1;add&rest;addres3

But when I want to pass the string to the tokenize function it looks
like this:

inString="name;address1;add ";


?????

Do you still want to see the tokenize function?

Can you help me now? Go on..


Enda

 
Reply With Quote
 
=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?=
Guest
Posts: n/a
 
      08-25-2006
wrote:
> Bo Persson wrote:
>> <> skrev i meddelandet
>> news: oups.com...
>>> Victor Bazarov wrote:
>>>> The error is in your tokenize function, on line 42. See FAQ 5.8.
>>>>
>>> How could the problem be in the tokenize function as the string
>>> paramerer to this function is already broken by the & character
>>>

>> It is a joke, sort of.
>>
>> You asked what is wrong with the tokenize function, but you don't show
>> us any of the code. So Victor guessed that it might be on line 42. (Or
>> it might be somewhere else. We don't know.)
>>
>>
>> Bo Persson

>
>
> Dudes.
>
> Still broken even when no spaces in the input string.
>
> name;address1;address2;addres3
> results in
> inString="name;address1;address2;addres3";
>
>
> name;address1;add&rest;addres3 <<--- look no spaces
> results in
> inString="name;address1;add ";
>
>
> I didn't think the tokenize code was necessary as the problem arrises
> before the call to the tokenize function. The problem is the string
> escapes at the & character. Why?
>
>
> A little more background: the string is a parameter to an exe.
>
> configman.exe -list name;address1;add&rest;addres3
>
> But when I want to pass the string to the tokenize function it looks
> like this:
>
> inString="name;address1;add ";

The above info would have been nice it the first place. Provide
relevant info.

Anyway. On some systems you might need to quote command
line arguments or escape certain characters as it might treat certain
characters as special.
Read the docs for your command line interpreteter, or take a quess
and try to invoke it as
configman.exe -list "name;address1;add&rest;addres3"
or
configman.exe -list 'name;address1;add&rest;addres3'
 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      08-25-2006
keepyourstupids...@yahoo.co.uk wrote:
> Bo Persson wrote:
> > <> skrev i meddelandet
> > news: oups.com...
> > > Victor Bazarov wrote:


> > >> The error is in your tokenize function, on line 42. See FAQ 5.8.
> > >
> > > How could the problem be in the tokenize function as the string
> > > paramerer to this function is already broken by the & character

> >
> > It is a joke, sort of.
> >
> > You asked what is wrong with the tokenize function, but you don't show
> > us any of the code. So Victor guessed that it might be on line 42. (Or
> > it might be somewhere else. We don't know.)

>
> Still broken even when no spaces in the input string.
>
> name;address1;address2;addres3
> results in
> inString="name;address1;address2;addres3";
>
>
> name;address1;add&rest;addres3 <<--- look no spaces
> results in
> inString="name;address1;add ";
>
>
> I didn't think the tokenize code was necessary as the problem arrises
> before the call to the tokenize function. The problem is the string
> escapes at the & character. Why?
>
>
> A little more background: the string is a parameter to an exe.
>
> configman.exe -list name;address1;add&rest;addres3
>
> But when I want to pass the string to the tokenize function it looks
> like this:
>
> inString="name;address1;add ";
>
>
> ?????
>
> Do you still want to see the tokenize function?



POST THE CODE

post a complete compilable program. State what the program does
and what you expect it to do

--
Nick Keighley

 
Reply With Quote
 
keepyourstupidspam@yahoo.co.uk
Guest
Posts: n/a
 
      08-25-2006

Nick Keighley wrote:
> keepyourstupids...@yahoo.co.uk wrote:
> > Bo Persson wrote:
> > > <> skrev i meddelandet
> > > news: oups.com...
> > > > Victor Bazarov wrote:

>
> > > >> The error is in your tokenize function, on line 42. See FAQ 5.8.
> > > >
> > > > How could the problem be in the tokenize function as the string
> > > > paramerer to this function is already broken by the & character
> > >
> > > It is a joke, sort of.
> > >
> > > You asked what is wrong with the tokenize function, but you don't show
> > > us any of the code. So Victor guessed that it might be on line 42. (Or
> > > it might be somewhere else. We don't know.)

> >
> > Still broken even when no spaces in the input string.
> >
> > name;address1;address2;addres3
> > results in
> > inString="name;address1;address2;addres3";
> >
> >
> > name;address1;add&rest;addres3 <<--- look no spaces
> > results in
> > inString="name;address1;add ";
> >
> >
> > I didn't think the tokenize code was necessary as the problem arrises
> > before the call to the tokenize function. The problem is the string
> > escapes at the & character. Why?
> >
> >
> > A little more background: the string is a parameter to an exe.
> >
> > configman.exe -list name;address1;add&rest;addres3
> >
> > But when I want to pass the string to the tokenize function it looks
> > like this:
> >
> > inString="name;address1;add ";
> >
> >
> > ?????
> >
> > Do you still want to see the tokenize function?

>
>
> POST THE CODE
>
> post a complete compilable program. State what the program does
> and what you expect it to do
>
> --
> Nick Keighley



Thanks guys the quotes worked, you are all really really clever people.


Enda

 
Reply With Quote
 
Marcus Kwok
Guest
Posts: n/a
 
      08-25-2006
wrote:
> A little more background: the string is a parameter to an exe.
>
> configman.exe -list name;address1;add&rest;addres3
>
> But when I want to pass the string to the tokenize function it looks
> like this:
>
> inString="name;address1;add ";
>
>
> ?????
>
> Do you still want to see the tokenize function?
>
> Can you help me now? Go on..


<OT>
If the string is being passed in on the command line, then it is your
command interpreter that is doing the conversion. On Windows Command
Prompt, the ampersand is used to chain together commands, like
"dir&echo hi" will execute the "dir" command, then execute the "echo hi"
command.

If you want to pass the ampersand into your program, put it in double
quotes.
</OT>

Try passing your command line arguments to this program to see exactly
what is happening:


#include <iostream>

int main(int argc, char* argv[])
{
for (int i = 0; i < argc; ++i) {
std::cout << "argv[" << i << "] = " << argv[i] << '\n';
}
}


--
Marcus Kwok
Replace 'invalid' with 'net' to reply
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cgi and escapeHTML but not ampersand Marek Perl Misc 5 08-31-2009 11:03 AM
Google-like query tokenizer aaronfude@gmail.com Java 6 07-08-2006 10:12 AM
Ampersand problem Rodusa ASP .Net 3 02-09-2005 02:33 PM
ASP.NET Httphandler and file names with ampersand = 404 Error. Please help. Prasanna Padmanabhan ASP .Net 1 07-08-2004 02:30 PM
Ampersand in attribute tfortney ASP .Net 4 04-28-2004 10:22 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57