ARGH! How the hell do you remove a character from a string... (STILL UNRESOLVED)
Ok, this is really starting to bug me...
How do you remove a character from a string WITHOUT replacing the whole string? I've printed an example below.
This is the text I want to change. I've split it into the sections it's sent in, and each section is searched before it's appendeed to the end.
Code:
ÿ‚[N 10:48am 150/150hp 504/504m 706mv 1000xp> ÿù
Code:
ÿ‚[N 10:48am 150/150hp 504/504m 706mv 1000xp> ÿùThere is 1 character on you can see (yourself).
The most characters on since the last reboot has been 2.
=========---========= Vinarian Legends =========---=========
=========---========= "Dream the Dream..." =========---=========
-=-=-=-=-=--=-=-=-=-=-
=========---========= I m m o r t a l s =========---=========
=========---========= O n l i n e =========---=========
<***> Tiiyakanah de Tera, Bringer of Chaos and Order (H)
-=-=-=-=-=--=-=-=-=-=-
=========---========= M o r t a l s =========---=========
=========---========= O n l i n e =========---=========
For more info on maxon and other mud related stats type mudstats.
ÿ‚[N 10:48am 150/150hp 504/504m 706mv 1000xp> ÿù
So each one of those 'code' bits ('s really just there coz it's a monotyped font) is a seperate string, but when appended to the end of an rtf text box, they make up the entire string. But anyway, as each section comes in, I want to search it for escape sequences (not shown, but they're chr(27) and [) and those annoying y and u things...
And ideas? Oh, and this text ocmes in through Winsock's Recv function if that's any help.
Thanks.
Last edited by esmerelda; Oct 31st, 2002 at 11:19 AM.
Not sure at all what do you want to "remove" but there is a Replace function in VB6 to replace text with some other text:
strNewText = Replace(strOldText,"search_char","replace_char")
In your case (I guess) "replace_char" should be empty string.
How do you remove a character from a string WITHOUT replacing the whole string
you're working in VB now, not C. I C you could find the character you want to delete and do a move to bring the rest of the string left one char, but in VB you can't do that, you have to do what I assume you mean by "replace the whole string". If you're putting everything somewhere else anyway, then that's a different story, since you can just transfer up to the bad char and then transfer after the bad char and you're not replacing anything.
I just erad your post again and here is what I think: you're actually looking for a way to replace binary characters ("ÿ" and "ù", etc...). I don't believe Replace function will do the job quite correctly simply because god only nows what those chars really are. So you may end up with looking for something that doesn't exist (unless you convert those chars to an ASCII code).
Originally posted by phinds and by the way, chr(27) is ESC, and those strings are called "ESCape strings" --- they're used by printers and other things as control sequences.
I know that you twot, why do you think I typed chr(27) instead of ESC? Because most people don't know what the hell I'm on about if I do *pokes you hard*
Originally posted by IROY55 I just erad your post again and here is what I think: you're actually looking for a way to replace binary characters ("ÿ" and "ù", etc...). I don't believe Replace function will do the job quite correctly simply because god only nows what those chars really are. So you may end up with looking for something that doesn't exist (unless you convert those chars to an ASCII code).
What I want to do is replace certain sets of characters, ESCape codes *glares* and those annoying extended ascii codes, to RTF colour codes and blank spaces respectively. How do you replace them, or remove them by replacing them with "" 's easily? Are you seriously saying there is no way of ever removing the anomolous characters easily? (Anomolous means ones which aren't normal/wanted).
can you save in a text file the string "as is"?
I work with strings that contains control codes like Cr, Lf, STX, ETX, EOT, etc., and the same method that I posted at your other thread asking this...is the one that I use...
post in a zip file the text file and tell me what are the strings that you don't want and I'll make you something that will work with your "real" data...
"Who Dares Wins" - "Quien se Arriesga Gana"
Mail me at:
... Are you seriously saying there is no way of ever removing the anomolous characters easily? ...
That's exactly right, unfirtunately. The real problem is that you don't know what to look for as those Binary/Unicode characters are unknown yet as you will have to "translate" (convert if you will) them (if it is possible at all).
Originally posted by D12Bit can you save in a text file the string "as is"?
I work with strings that contains control codes like Cr, Lf, STX, ETX, EOT, etc., and the same method that I posted at your other thread asking this...is the one that I use...
post in a zip file the text file and tell me what are the strings that you don't want and I'll make you something that will work with your "real" data...
Yep. I've logged a session to a text file and attached it.
Oh, and if you take off the .txt extension, it'll show the actual rtf file.
I do actually know what you want to do. Is it to just get rid of the characters in place, is this what you mean by not replacing the whole string. If so then just scan the data and replace any non-ASCII characters with spaces (Of course, not cr, lf, tabs). You will need to write a function to do this. I do have such a function if you would like it.
Use the following functions to determine if the character is ASCII and then replace it with a space
Oh, also, I want it to remove the CSCMD_ strings when it searches for them. But seeing that the thing whassisname posted above, it's causing me a great deal of headaches...