Friday, December 7, 2012

String escaping utilities in Peoplecode



The following is the peoplecode program to show string escaping utilities:


[code]
Local JavaObject &escUtils = GetJavaClass("org.apache.commons.lang.StringEscapeUtils");

Local string &String = """Hello World!""";

Local string &jescString = &escUtils.escapeJava(&String);
MessageBox(0, "", 0, 0, "The string in java escape sequence is" | ": " | &jescString);

Local string &htmlescString = &escUtils.escapeHtml(&String);
MessageBox(0, "", 0, 0, "The string in html escape sequence is" | ": " | &htmlescString);

Local string &jscriptescString = &escUtils.escapeJavaScript(&String);
MessageBox(0, "", 0, 0, "The string in javascript escape sequence is" | ": " | &jscriptescString);


Local string &sqlescString = &escUtils.escapeSql(&String);
MessageBox(0, "", 0, 0, "The string in sql escape sequence is" | ": " | &sqlescString);


Local string &xmlescString = &escUtils.escapeXml(&String);
MessageBox(0, "", 0, 0, "The string in xml escape sequence is" | ": " | &xmlescString);
[/code]

The following is the output:



PeopleTools 8.50 - Application Engine
Copyright (c) 1988-2012 PeopleSoft, Inc.
All Rights Reserved


The string in java escape sequence is: \"Hello World!\" (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The string in java escape sequence is: \"Hello World!\" (0,0) (0,0)

The string in html escape sequence is: "Hello World!" (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The string in html escape sequence is: "Hello World!" (0,0) (0,0)

The string in javascript escape sequence is: \"Hello World!\" (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The string in javascript escape sequence is: \"Hello World!\" (0,0) (0,0)

The string in sql escape sequence is: "Hello World!" (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The string in sql escape sequence is: "Hello World!" (0,0) (0,0)

The string in xml escape sequence is: "Hello World!" (0,0)
 Message Set Number: 0
 Message Number: 0
 Message Reason: The string in xml escape sequence is: "Hello World!" (0,0) (0,0)
Application Engine program TST_APPENGIN ended normally


Based on the language like java,javascript or xml, the string gets seperated. This would be useful for pattern matching.

3 comments:

ProfAshok said...

peter your blog is a technical manual. I followed you back from your valubale comment on mine. best wishes.

peterparker - Servant of BHAGWAN PARASHURAMA said...

@Ashok: Kindly elaborate what you meant by saying technical manual? Thanks. :)

peterparker - Servant of BHAGWAN PARASHURAMA said...

@Ashok sir: And thanks for giving me best wishes. :)