473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to identify control characters in a url and remove those using php

Hello,

How to identify control characters in a url and remove those using php?

Thanks.
Oct 4 '10 #1
1 2062
kovik
1,044 Expert 1GB
Control characters? Like, ASCII control characters? You could either just use urlencode(), or you could go through the string removing characters with the ASCII value 0 to 31 and 127.

Expand|Select|Wrap|Line Numbers
  1. function kill_ctrl_chars($data) {
  2.     $formatted_data = '';
  3.  
  4.     for ($i = 0, $max = strlen($data); $i < $max; $i++) {
  5.         $ascii_value = ord($data[$i]);
  6.  
  7.         if (($ascii_value > 31 || $ascii_value < 0) && $ascii_value != 127) {
  8.             $formatted_data .= $data[$i];
  9.         }
  10.     }
  11.  
  12.     return $formatted_data;
  13. }
Oct 5 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Greg Lindstrom | last post by:
Hello- I have a text file generated on a HP-9000 running HP-Unix with embedded control characters and would like to read it in, modify it, and write it out in PDF format. The new page character...
2
by: andy | last post by:
Greetings all. Problem: Have control characters mostly ^B which are loaded into a table in our database forming part or a narative field. In TOAD these appear as a thick bar - kind of like a pipe...
2
by: nowhere | last post by:
Hi, I need to preserve some ASCII control characters (CR and LF) within an XML file so I have included the data in a CDATA section. However, when parsing it using expat, I lose the CR...
8
by: Peter O'Reilly | last post by:
I have an HTML form with a textarea input box. When the user conducts a post request (e.g. clicks the submit button), an HTML preview page is presented to them with the information they have...
1
by: rcamarda | last post by:
Beyond my control: I am finding control characters (likely tab) is making its way into address fields of our operational system. This is messing me up when I load the data into our warehouse w/ BCP...
1
by: Fred Nelson | last post by:
Hi: I'm writing an error handling system for my vb.net windows application. I have an error trapping routine that is catching all unexpected errors, writing an entry in an sql database and...
3
by: Frank Niessink | last post by:
Hi list, First of all, I wish you all a happy 2006. I have a small question that googling didn't turn up an answer for. So hopefully you'll be kind enough to send me in the right direction. ...
11
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am trying to have the data in the barcode be displayed in...
2
by: Bazza Formez | last post by:
I have a bound field in a DetailsView control that displays free form description type data from my SQL database table (typical data is a couple of paragraphs of written product description being...
7
by: wannymahoots | last post by:
optparse seems to be escaping control characters that I pass as arguments on the command line. Is this a bug? Am I missing something? Can this be prevented, or worked around? This behaviour...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.