how to remove the non keyboard specialcharecters from string

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Begin by identifying the complete set of "special characters". Then use a Convert() function to replace them with a zero-length string.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
uppalapati2003
Participant
Posts: 70
Joined: Thu Nov 09, 2006 2:14 am

Post by uppalapati2003 »

those special charecters are not constent our sorce as files because of that i am getting different type of non keyboard special charecters.
only one thing i have to do other than A to Z and 0 to 9 remaining charecters i need to remove from the string .
how to do that please guide me.
Srini
BugFree
Participant
Posts: 82
Joined: Wed Dec 13, 2006 6:02 am

Post by BugFree »

This is a parallel routine that i wrote. And meets your requirement.

Code: Select all

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char* DeleteChars(char *inputstring)
{

	char *OutPut= (char *)malloc (sizeof(char *));

	int length = 0;

	int StringLength = strlen(inputstring);

	if (length == 0)
		OutPut[length] = '\0';
	else
	{
		while(*inputstring)
        	{
			if ((*inputstring>= 32) && (*inputstring<= 126))
                	{
				OutPut[length] = *inputstring;

				length++;
			}
			inputstring++;
		}
		OutPut[length] = '\0';
	}


return OutPut;

free(OutPut);

}
Hope this helps.
Last edited by BugFree on Thu Mar 27, 2008 5:51 am, edited 1 time in total.
Ping me if I am wrong...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Just curious; where does the variable called "i" get its value? You test it in

Code: Select all

(i == 0) 
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
BugFree
Participant
Posts: 82
Joined: Wed Dec 13, 2006 6:02 am

Post by BugFree »

ray.wurlod wrote:Just curious; where does the variable called "i" get its value? You test it in

Code: Select all

(i == 0) 
...
:oops: :oops:

Copy paste error. I changed it in the post. Tested it and it is working.
Ping me if I am wrong...
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I remember building something like this a while back. Check the following post for reference.
viewtopic.php?t=108011&postdays=0&posto ... g&start=15
Bugfree, get rid of free(OutPut); from you code as it will never be executed. The engine will take care of freeing the memory.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
BugFree
Participant
Posts: 82
Joined: Wed Dec 13, 2006 6:02 am

Post by BugFree »

:) I have read somewhere in the forum that the memory has to be explicitly handled in the parallel routine. so the free(OutPut). I dint know that the parallel engine will take care of the memory clean up.
Ping me if I am wrong...
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

It is true that memory management needs to be handled but no statements after a "Return" statement gets executed, hence the request to get rid of it.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply