Solved

Javascript and control characters

Posted on 2004-08-05
7
666 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now