Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Javascript and control characters

Posted on 2004-08-05
7
Medium Priority
?
679 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

916 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