Help - Search - Members - Calendar
Full Version: string8::replace_string
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
cookir
i know, the last 3 topics are now from me. sorry. i've only been doing this a week, and i'm feeble.

i'm having a problem with the replace_string function, whatever values for len1 and len2 i pass it, it wont replace something at the end. i'll explain by way of example

i have something similar to
CODE

string8 artist = "whatever"; // you get the idea
string8 title = "whatever2";

string8 line = "i like fish, but not more than %artist% when they play %title%";

line.replace_string("%artist%", 8, artist, artist.length(),0,0);
line.replace_string("%title%", 7, title, title.length(), 0, 0);


and when run, the %artist% replaces fine, but the %title% stays as it is.... weird.

it doesn't seem to matter what values i pass as len1 and len2, but if there's something after the %title% in line then it fixes it, but surely that's not right.... i'm figuring i'm just not giving it right values or something...

can anyone shed some light on this? i'm stuffed
cookir
guess not

ive just added a long bit of random text to the string, then after replace i'm taking it off again.

blink.gif
Peter
Possibly a bug in replace_string function itself. Use something else for now.
mat128
Possibly in your code...

See:
CODE

line.replace_string("%artist%", 8, artist, artist.length(),0,0);
line.replace_string("%title%", 7, title, title.length(), 0, 0);


At the end of your %title% line, there are spaces "(), 0, 0);" and not in the %artist% one "(),0,0);"

Maybe, maybe not.

Mat
cookir
QUOTE
Possibly a bug in replace_string function itself. Use something else for now.


Ah, I've botched a work around biggrin.gif

QUOTE
At the end of your %title% line, there are spaces "(), 0, 0);" and not in the %artist% one "(),0,0);"

Maybe, maybe not.


Not. I promise.
kode54
In PFC\string.cpp, replace
CODE
while(ptr+len1<len)

with
CODE
while(ptr+len1<=len)
cookir
yay it works

thanks smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.