Solved

Javascript and control characters

Posted on 2004-08-05
7
669 Views
Last Modified: 2008-03-06
Heya Experts,

(Linux, Apache, Javascript)

I have a form which is being created dynamically. It has couple of fields with 1-10 in size. The form collects the data, verifies it and sends the data (form.field.value)  to a cgi program. The cgi (C) program gets the data through its arguments.

cgi.exe  -f1 data1 -f2 data2 ...

The issue occurs when the data contains control/special characters. I suppose Javascript (or Browser) handles that. For example;
If I enter ampersand (!) character in the first field, it gets

cgi.exe -f1 "\041" ... (octal value)

Can anyone please give me some pointers about how to print the ascii value of it, instead of octals? Again, it is a dynamic form/field there is no special replacement at users end. They may enter anything they want.

Cheers,
0
Comment
Question by:malatya
  • 3
  • 2
7 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 11727372
Hi

Since it's probably the browser, at the cgi end, can't you use oct to change the octal number to a decimal. Then, use chr to figure it's character out.

Regards,
Zyloch
0
 

Author Comment

by:malatya
ID: 11729276
Zyloch, thanks for the comment. Unfortunately, it is not easy to convert the octals to ascii at cgi end. Not impossible but the argument might be composed of octals and asciis together. You need to differenciate the charcter whether it is octal/hex or ascii then do something accordingly.
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11729589
You might try this at the perl end:

s/\\(d+){3}/chr(oct($+))/gi

Regards,
${Zyloch}
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:malatya
ID: 12071066
Actually, I found a solution. Before the scripts pass the arguments to cgi it echoes with -e option and works perfectly.

(bash) echo -e <the argument> > cgi

0
 
LVL 36

Expert Comment

by:Zyloch
ID: 12071082
Ah, that's good, then you should post in Community Support to close and refund this question. Glad you figured it out :)
0
 
LVL 2

Accepted Solution

by:
Lunchy earned 0 total points
ID: 12080092
Closed, 100 points refunded.
Lunchy
Friendly Neighbourhood Community Support Admin
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question