This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

using special characters in text output

Help for those learning Tcl or writing their own scripts.
Post Reply
r
renegad3
Voice
Posts: 1
Joined: Sat Apr 16, 2011 10:23 am

using special characters in text output

Post by renegad3 »

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.
w
willyw
Revered One
Posts: 1209
Joined: Thu Jan 15, 2009 12:55 am

Re: using special characters in text output

Post by willyw »

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: Select all

putserv "privmsg #channel : /!\\ some other text follows  "
Like that?

When I tried it, it looked like what you described.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Re: using special characters in text output

Post by speechles »

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: Select all

putserv "privmsg #channel : /!\\ some other text follows  " 
Using substitution to your advantage, yields the code below.

Code: Select all

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: Select all

putserv "privmsg #channel :\037/!\x5c\037 some other text follows  " 
Post Reply