473,385 Members | 1,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Tokenizer does not like ampersand

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

Aug 25 '06 #1
9 2340
ke****************@yahoo.co.uk 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
Aug 25 '06 #2

Victor Bazarov wrote:
ke****************@yahoo.co.uk 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

Aug 25 '06 #3
ke****************@yahoo.co.uk 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
Aug 25 '06 #4

<ke****************@yahoo.co.ukskrev i meddelandet
news:11**********************@m73g2000cwd.googlegr 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
Aug 25 '06 #5

Bo Persson wrote:
<ke****************@yahoo.co.ukskrev i meddelandet
news:11**********************@m73g2000cwd.googlegr 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

Aug 25 '06 #6
ke****************@yahoo.co.uk wrote:
Bo Persson wrote:
><ke****************@yahoo.co.ukskrev i meddelandet
news:11**********************@m73g2000cwd.googleg roups.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'
Aug 25 '06 #7
keepyourstupids...@yahoo.co.uk wrote:
Bo Persson wrote:
<ke****************@yahoo.co.ukskrev i meddelandet
news:11**********************@m73g2000cwd.googlegr 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

Aug 25 '06 #8

Nick Keighley wrote:
keepyourstupids...@yahoo.co.uk wrote:
Bo Persson wrote:
<ke****************@yahoo.co.ukskrev i meddelandet
news:11**********************@m73g2000cwd.googlegr 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

Aug 25 '06 #9
ke****************@yahoo.co.uk 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
Aug 25 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: debk | last post by:
Server.UrlEncode is not longer converting the ampersand in a string to %26 so the value passed in the querystring gets truncated in the following page. Is this a problem with IIS, does anyone know?...
5
by: Knackeback | last post by:
task: - read/parse CSV file code snippet: string key,line; typedef tokenizer<char_separator<char> > tokenizer; tokenizer tok(string(""), sep); while ( getline(f, line) ){ ++lineNo;...
4
by: Java Guy | last post by:
This must be a classical topic -- C++ stgring tokenizer. I just switched from C to C++ ( in Unix ). It turns out that there is no existing C++ string tokenizer. Searching on the Web, I found...
10
by: Lorenzo J. Lucchini | last post by:
Do you see any counter-indication to a token extractor in the following form? typedef int token; token ExtractToken(const char** String, char* Symbol); If it finds a valid token at the start...
4
by: tfortney | last post by:
I created an iframe HtmlGenericControl that has an ampersand in the "src" attribute..... Dim faxFrame As New HtmlGenericControl("iframe") faxFrame.Attributes.Add("width", "100%")...
18
by: Robbie Hatley | last post by:
A couple of days ago I dedecided to force myself to really learn exactly what "strtok" does, and how to use it. I figured I'd just look it up in some book and that would be that. I figured...
1
by: JamesHoward | last post by:
I have searched the board and noticed that there isn't really any sort of good implementation of a string tokenizer that will tokenize based on a custom set of tokens and return both the tokens and...
4
by: Kiran Makam | last post by:
I am setting the content of a div dynamically using innerHTML property. If the content contains an ampersand, text after the ampersand is disappearing in IE6. It works properly in Firefox. This...
1
by: Karl Kobata | last post by:
Hi Fredrik, This is exactly what I need. Thank you. I would like to do one additional function. I am not using the tokenizer to parse python code. It happens to work very well for my...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.