egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

using special characters in text output

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
renegad3
Voice


Joined: 16 Apr 2011
Posts: 1

PostPosted: Sat Apr 16, 2011 10:34 am    Post subject: using special characters in text output Reply with quote

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
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Sat Apr 16, 2011 11:28 am    Post subject: Re: using special characters in text output Reply with quote

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
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat Apr 16, 2011 7:07 pm    Post subject: Re: using special characters in text output Reply with quote

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. Wink
Code:
putserv "privmsg #channel :\037/!\x5c\037 some other text follows  "

_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber