| View previous topic :: View next topic |
| Author |
Message |
renegad3 Voice
Joined: 16 Apr 2011 Posts: 1
|
Posted: Sat Apr 16, 2011 10:34 am Post subject: using special characters in text output |
|
|
working on a small script to output text to an irc channel with eggdrop.
Is it possible to force the output to contain the \ as a character as opposed to it prefixing an actual code, such as a color code?
I would like the output to appear as: /!\ some other text follows
Thanks for any help, btw, I did try searching, but couldnt find any pointers. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sat Apr 16, 2011 11:28 am Post subject: Re: using special characters in text output |
|
|
| renegad3 wrote: | working on a small script to output text to an irc channel with eggdrop.
Is it possible to force the output to contain the \ as a character as opposed to it prefixing an actual code, such as a color code?
I would like the output to appear as: /!\ some other text follows
Thanks for any help, btw, I did try searching, but couldnt find any pointers. |
| Code: |
putserv "privmsg #channel : /!\\ some other text follows "
|
Like that?
When I tried it, it looked like what you described. |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat Apr 16, 2011 7:07 pm Post subject: Re: using special characters in text output |
|
|
| renegad3 wrote: | working on a small script to output text to an irc channel with eggdrop.
Is it possible to force the output to contain the \ as a character as opposed to it prefixing an actual code, such as a color code?
I would like the output to appear as: /!\ some other text follows
Thanks for any help, btw, I did try searching, but couldnt find any pointers. |
The problem is that character is a "literal" escape, "\". It has special meaning in it's \ form. So what you can do is use the power of substitution and double-quotes to your advantage. The hexadecimal character code for \ is 5c. So doing something like this, makes it no longer a special character causing issues, and using it with double-quotes allows it to return to the character it represents through substitution.
This is how everyone will suggest doing it, like willyw's advice above. But not knowing tcl syntax, it's golden rules, and what an escape can cause. Using this can/will lead to several issues.
| Code: | | putserv "privmsg #channel : /!\\ some other text follows " |
Using substitution to your advantage, yields the code below.
| Code: | | putserv "privmsg #channel : /!\x5c some other text follows " |
The beauty of doing this, is that you no longer need to care what your escape may influence. Wherever you would normally use "\" within your double-quotes, instead use "\x5c" and it solves the problem. The same can be done for any problem characters, and this also solves matching issues.
The code below, adds underlines around your triangle, which will give it the bottom it lacks. Try the code below.
| Code: | | putserv "privmsg #channel :\037/!\x5c\037 some other text follows " |
_________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|