Control character or Unprintable character in 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
sharma
Premium Member
Premium Member
Posts: 46
Joined: Mon Dec 24, 2007 2:16 pm

Control character or Unprintable character in string

Post by sharma »

Hi,

I want to check whether the string contain control character /Unprintable character in it.

How do i check in the transformer stage .

Is there any function is there to check the same??

Can i check by their Ascii values ??? But how in DS.

Regards
~Nirmal
Nirmal Sharma
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Try using AlNum if its Alpha numeric, or Alpha if only string.
Optionally IsValid for specific datatypes.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
sharma
Premium Member
Premium Member
Posts: 46
Joined: Mon Dec 24, 2007 2:16 pm

Post by sharma »

ALNum() function checks only for alpha numeric character in the string.

But i actually wanna check .... whatever string i am using should have ASCII characters between 32 and 127.If any of the character is outside this range,it should reject that string.
Nirmal Sharma
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Write yourself a little routine.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

If you are ready to use Server jobs, there are more functions available like chr(), ascii() etc.,
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
sharma
Premium Member
Premium Member
Posts: 46
Joined: Mon Dec 24, 2007 2:16 pm

Post by sharma »

chr() is also there in parallel jobs but ascii() function is not there in parallel jobs.

But i am not sure how to check for an control character within a string using chr() function.
Nirmal Sharma
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Prefer Seq() function. Seq() returns the ASCII code value associated with a character.

If you have NLS enabled and are using multi-byte encoding, prefer UniSeq() to Seq(). UniSeq() returns the Unicode code value associated with a character. If you have a single-byte character set, UniSeq() returns the same result as Seq().
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
John Smith
Charter Member
Charter Member
Posts: 193
Joined: Tue Sep 05, 2006 8:01 pm
Location: Australia

Re: Control character or Unprintable character in string

Post by John Smith »

sharma wrote:Hi,

I want to check whether the string contain control character /Unprintable character in it.

How do i check in the transformer stage .

Is there any function is there to check the same??

Can i check by their Ascii values ??? But how in DS.

Regards
~Nirmal
You can use the "od" command outside of DS; but that's in Unix unfortunately. You could do this before you run the job meaning run the script to check and cleanse the file prior.
I believe the others have chipped in on doing it in DS ; just offering an alternative.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Use this logic in your parallel routine:

Ref THIS post also.

Code: Select all

#define NP_RANGE_START  32 
#define NP_RANGE_END    127 


bool IsCharNP(char InCharToCheck ) 
{ 
   bool IsNotPrintable = false; 

   if( (InCharToCheck > NP_RANGE_START  ) && ( InCharToCheck < NP_RANGE_END )) 
   { 
      IsNotPrintable = false; 
   } 
   else 
   { 
      IsNotPrintable =  true; 
   } 
    
   return IsNotPrintable; 
} 
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That's not generally true. All printable accented characters are between 129 and 255.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

OP asked for it. Specifically!
sharma wrote:whatever string i am using should have ASCII characters between 32 and 127.If any of the character is outside this range,it should reject that string.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
Post Reply