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 

Problem with special characters ² ³ and °
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
tomcat
Voice


Joined: 11 Dec 2008
Posts: 7

PostPosted: Thu Dec 11, 2008 5:07 am    Post subject: Problem with special characters ² ³ and ° Reply with quote

Hi i have some problems with ² ³ and ° i want to replace them with \² \³ and \° but for example
regsub -all -- \\\³ $data \\\³ data does not work Sad
some guys told me to use
regsub -all -- {(\\|\[|\]|\&|\{|\}|"|'|\262|\263)} $data {\\\1} data
to remove all special characters. It works fine with []{}&\'" but not with ², ³ or °
Can anyone help me and tell me what to do to get what i need ?
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Thu Dec 11, 2008 8:43 am    Post subject: Reply with quote

did u try?
Code:
regsub -all "°" $data "" data
Back to top
View user's profile Send private message Visit poster's website
tomcat
Voice


Joined: 11 Dec 2008
Posts: 7

PostPosted: Thu Dec 11, 2008 10:04 am    Post subject: Reply with quote

does not work
Back to top
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Thu Dec 11, 2008 10:26 am    Post subject: Reply with quote

Make sure your script has the right encoding (check '.tcl encoding system'), or, if you're using Tcl >= 8.5, use the -encoding option when loading the script.

tomcat wrote:
regsub -all -- \\\³ $data \\\³ data does not work Sad

Are you sure? Laughing It probably works, but you're replacing "\³" with "\³", so it is kind of hard to spot the difference Smile
_________________
Have you ever read "The Manual"?
Back to top
View user's profile Send private message
tomcat
Voice


Joined: 11 Dec 2008
Posts: 7

PostPosted: Thu Dec 11, 2008 1:47 pm    Post subject: Reply with quote

proc filt {data} {
regsub -all -- {(\\|\[|\]|\&|\{|\}|"|'|\262|\263)} $data {\\\1} data
return $data

or

proc filt {data} {
regsub -all -- {(\\|\[|\]|\&|\{|\}|"|'|\²|\³)} $data {\\\1} data
return $data

does not work -.-

Its an eggdrop script how to use the -encoding option ?
Back to top
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Thu Dec 11, 2008 2:13 pm    Post subject: Reply with quote

tomcat wrote:
how to use the -encoding option ?

source -encoding <encoding used in your script> script.tcl
_________________
Have you ever read "The Manual"?
Back to top
View user's profile Send private message
tomcat
Voice


Joined: 11 Dec 2008
Posts: 7

PostPosted: Thu Dec 11, 2008 2:32 pm    Post subject: Reply with quote

source -encoding iso-8659-1 scripts/scanner.tcl
results in crash...
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Thu Dec 11, 2008 3:32 pm    Post subject: Reply with quote

tomcat wrote:
source -encoding iso-8659-1 scripts/scanner.tcl
results in crash...


tcl version 8.5.x? because its option from 8.5 Smile
Back to top
View user's profile Send private message Visit poster's website
tomcat
Voice


Joined: 11 Dec 2008
Posts: 7

PostPosted: Thu Dec 11, 2008 4:07 pm    Post subject: Reply with quote

8.5.5
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Thu Dec 11, 2008 4:11 pm    Post subject: Reply with quote

tomcat wrote:
8.5.5


try:
Code:
source -encoding iso8859-1 scripts/scanner.tcl


u mean 8859 not 8659? ;p

:>
Back to top
View user's profile Send private message Visit poster's website
tomcat
Voice


Joined: 11 Dec 2008
Posts: 7

PostPosted: Thu Dec 11, 2008 4:38 pm    Post subject: Reply with quote

I tried iso 8859 the other is not known and utf-8

it doesnt matter ² ³ ° still dont get replaced with \² \³ \°
Back to top
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Thu Dec 11, 2008 4:55 pm    Post subject: Reply with quote

damn, I have no problem with this char on my bot

u can always try to change this char to its code number, and after that u can delete it from whole string or smth :>

do some trigger and simple IF, !test <special_char> and after in test script if {$arg == "special_char"} { puts "its ok" }

cause we dont know what is current wrong Razz
like user wrote, that can be smth with codepage ;]
Back to top
View user's profile Send private message Visit poster's website
tomcat
Voice


Joined: 11 Dec 2008
Posts: 7

PostPosted: Thu Dec 11, 2008 5:13 pm    Post subject: Reply with quote

We found a dirty but working way to fix it Smile
tnx all for help
Back to top
View user's profile Send private message
incith
Master


Joined: 23 Apr 2005
Posts: 275
Location: Canada

PostPosted: Mon Dec 22, 2008 2:00 pm    Post subject: Reply with quote

tomcat wrote:
We found a dirty but working way to fix it Smile
tnx all for help

Thank you for posting your solution.
_________________
; Answer a few unanswered posts!
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri Dec 26, 2008 9:37 am    Post subject: Reply with quote

An interesting subject.

I have long suffered the mystical art of fonts, code pages, encodings and the like.

Lets say I copy/paste from the character map tool in windows to build up a text string as follows :-

% set mytest "at xy³ + y² temperature is 14°"
at xy³ + y² temperature is 14°

An attempt to modify (add a backslash to) the special characters using their equivalent hex values and regsub does not work :-

% return [regsub -all -- {[\xB0\xB2\xB3]} $mytest "\\\\&"]
at xy³ + y² temperature is 14°

It should have worked. It seems clear that copy/paste from windows character map does not result in the expected hex characters in the Tcl interpreter I am using.

However, if we explicity use hex character notation to build up the exact same text string as follows :-

% set mytest "at xy\xB3 + y\xB2 temperature is 14\xB0"
at xy³ + y² temperature is 14°

It looks the same, but now using the same regsub statement :-

% return [regsub -all -- {[\xB0\xB2\xB3]} $mytest "\\\\&"]
at xy\³ + y\² temperature is 14\°

It works!

If it is any help to the original poster, if you are able to explicitly build up your string using hex notation then that would enable you to use hex notation in the regsub pattern successfully.

If not, then it remains a mystical art which will eventually result in insanity.
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
Goto page 1, 2  Next
Page 1 of 2

 
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