PtokaX forum

Development Section => Your Developing Problems => Topic started by: xjr13sp on 23 October, 2003, 20:02:11

Title: losting some characters
Post by: xjr13sp on 23 October, 2003, 20:02:11
Hi,

I have troubles with a script.
In this part of code I get a string value, but you know: I'm French and so, I will have many characters with accents and ponctuations.

CODE:

function Get2Args(data)
   s,e,whoTo,from,cmd,arg,arg2= strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(%S+)%s+([%w%s]+)")
   return arg,arg2
end

if (cmd=="!memo") then
   arg,arg2 = Get2Args(data)
   ........ actions
end if


The problem is befoer the line s,e,whoTo,from,cmd,arg,arg2=str...., my string value keeps all of the accents and ponctuations, but after passed this line, the string value is troncated at the first met accent!!

For example:
if I send the string "le niveau sup?rieur de grade", I will have "le niveau sup"
if I send the string "Quelqu'un m'a appel? ?", I will have "Quelqu "

Is someone knows why I have this problem? I use Ptokax...
Title:
Post by: raz on 23 October, 2003, 20:43:01
i don't have the sligest clue maybe if u post all of the script it will help more.
Title:
Post by: Skrollster on 23 October, 2003, 23:30:33
No the problem lies in here:

function Get2Args(data)
s,e,whoTo,from,cmd,arg,arg2= strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(%S+)%s+([%w%s]+)")
return arg,arg2
end

the sign " ' " isn't included in this: [%w%s]

use this code and it should work:

function Get2Args(data)
s,e,whoTo,from,cmd,arg,arg2= strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(%S+)%s+(.+)")
return arg,arg2
end
Title:
Post by: Skrollster on 23 October, 2003, 23:31:52
and this will also work:_

function Get2Args(data)
s,e,arg,arg2= strfind(data,"%b<>%s+(%S+)%s+(%S+)%s+(.+)")
return arg,arg2
end
Title:
Post by: OpiumVolage on 23 October, 2003, 23:34:10
Try to change you regex to:
s,e,arg,arg2= strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+%S+%s+(%S+)%s+(.+)")

or

s,e,arg,arg2= strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+%S+%s+(%S+)%s+(.+)|")

I think that this form was for excluding the "|" at the end.
Title:
Post by: Skrollster on 23 October, 2003, 23:37:57
opium your a bit slow :P
Title:
Post by: OpiumVolage on 23 October, 2003, 23:42:48
33.6k with dl running :)

But you are too fast :)

s,e,arg,arg2= strfind(data,"%b<>%s+%S+%s+(%S+)%s+(.+)")

There where 3 captures :)
Title:
Post by: Skrollster on 23 October, 2003, 23:46:14
feel sorry for you..

<== has 10bit download bandwith..
Title: Coooooooooooooooooooooool !!!!!!
Post by: xjr13sp on 23 October, 2003, 23:48:34
Thank you SO MUCH Skrollster!!!!
Your first idea was the good one. It works well.

Thank you too OpiumVolage for your help. I didn't test your solution, but I take note of this eventuality.....

Thousands thx  :))
Title:
Post by: OpiumVolage on 23 October, 2003, 23:49:16
DOn't feel sory, this mean i'm at home, ... and in vacations.
Title:
Post by: Skrollster on 24 October, 2003, 10:20:35
Opium: Ok, good for you :P

xjr13sp: if you just are looking for the arguments then the second post should work just as well but will use less resorces..