Author Topic: Escaping  (Read 2550 times)

0 Members and 1 Guest are viewing this topic.

Offline TTB

  • Lord
  • ***
  • Posts: 436
  • Karma: +17/-1
Escaping
« on: 07 February, 2008, 10:31:42 »
Hey,

I've some little client scripting. I created a #say command, which allows certain ppl to talk with the client. I've a problem: When users use the | character, the hub detects this as the end of a command
Code: [Select]
<INPUT> #say Test1|Test2|Test3
<OUTPUT> Test1
I'm using now this to escape this:
Code: [Select]
info = string.gsub(info, "%|", " ")My question: Is there a way to make it a | character without ending the command? I tried with:
Code: [Select]
info = string.gsub(info, "%|", "\|")but doesn't work. Any other ideas?

TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

PtokaX forum

Escaping
« on: 07 February, 2008, 10:31:42 »

Offline PPK

  • Administrator
  • Emperor
  • *****
  • Posts: 1 478
  • Karma: +209/-22
  • PtokaX developer
Re: Escaping
« Reply #1 on: 07 February, 2008, 15:53:17 »
You can escape pipe in two ways.
First is original dc protocol way, escaping | with /%DCN124%/
Second is DC++ way, escaping | with &#124;
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

Offline TTB

  • Lord
  • ***
  • Posts: 436
  • Karma: +17/-1
Re: Escaping
« Reply #2 on: 07 February, 2008, 16:59:31 »
Thank you PPK. Going to try!

After the try's:
Code: [Select]
info = string.gsub(info, "%|", "&#124;")     -- works
« Last Edit: 07 February, 2008, 17:13:08 by TTB »
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

PtokaX forum

Re: Escaping
« Reply #2 on: 07 February, 2008, 16:59:31 »