Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     convert double quote to "%22"

Read-Only Read-Only Topic
Go
Search
Notify
Tools
convert double quote to "%22"
 Login/Join
 
Silver Member
posted
i'm getting back a result set that has double quotes in it. for programatic reasons, i want to convert any double quotes to %22. how can i do this? i have no way of knowing in advance where the double quotes will appear or how many ther will be.


---------------------
WebFOCUS 7.6
 
Posts: 41 | Registered: August 05, 2005Report This Post
Expert
posted Hide Post
Dan, i would suggest using the string functions in the manual 'Using Functions'
and there would be a number of ways to do it, depending on the nature of the end result you want.
if CTRAN would't work for you
then a loop of POSIT and OVRLAY would do the trick.
-s
Here's a quick table of some useful (well, u b the judge) bytvals for the CTRAN function
ASCII bytvals for ctran function 
 
AMPERSAND 38 DASH 45 APOSTROPHE 39 COMMA 44 QUOTE 34 PERIOD 46 PIPE 124 
SLASH 47 BLANK 32 PLUS 43 UNDER 95 LEFTBRKT 60 RIGHTBRKT 62 POUND 35 
LEFTPAR 40 RIGHTPAR 41 LEFTBRACE 91 RIGHTBRACE 93 NUMZERO 48 EQUAL 61 DOLLAR 36 
ASTERISK 42 UNDERSCORE 95 ZERO 48 EACUTE 233 


so your CTRAN would want to change a 34 (quote) to something friendlier, like a single quote 39 or a blank 32.
With a single CTRAN on a field, you can nuke all the " and make them something else, regardless of how many.

This message has been edited. Last edited by: susannah,




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Platinum Member
posted Hide Post
Give this a whirl...

  
-*--------------------------------------------------------------
-* Replace all double quotes with %22
-*--------------------------------------------------------------

-* String to replace
-SET &FIELD = '"abc"def"ghi"';

-* Get the field length
-SET &FIELD_LEN = &FIELD.LENGTH;


-* Initialize variables
-SET &NEWSTR = '';
-SET &IDX = 1;

-* Iterate through the entire string a character at a time
-REPEAT :END_DBL WHILE &IDX LE &FIELD_LEN;

-* Get the next character in the string
-SET &CHARACTER = SUBSTR(&FIELD_LEN, &FIELD, &IDX, 
-                 &IDX, 1, 'A1');

-* Append %22 if a double quote is found,
-* otherwise append the character
-SET &NEWSTR = IF &IDX EQ 1 THEN (IF &CHARACTER EQ '"'
-THEN '%22' ELSE &CHARACTER)
-ELSE          IF &CHARACTER EQ '"' THEN &NEWSTR | '%22'
-ELSE          &NEWSTR | &CHARACTER;

-* Advance to the next character
-SET &IDX = &IDX + 1;

-:END_DBL
-*--------------------------------------------------------------

-TYPE FIELD : (&FIELD)
-TYPE NEWSTR: (&NEWSTR)


Regards,
Sean


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
 
Posts: 210 | Location: Ottawa | Registered: November 03, 2005Report This Post
Expert
posted Hide Post
Dan,

With release 7.x there is a new function called STRREP that should foot the bill precisely. It has been reported that it also works in 5.3.2 upwards but you would have to check. If you going to 7.1.x imminently then it would be worth using it.

From the help screens -

STRREP (inlength, instring, searchlength, searchstring, replength, repstring, outlength, outstring)

where:

inlength - Numeric
Is the number of characters in the input string.

instring - Alphanumeric
Is the input string.

searchlength - Numeric
Is the number of characters in the (shorter length) string to be replaced.

searchstring - Alphanumeric
Is the character string to be replaced.

replength - Numeric
Is the number of characters in the replacement string. Must be zero (0) or greater.

repstring - Alphanumeric
Is the replacement string (alphanumeric). Ignored if replength is zero (0).

outlength - Numeric
Is the number of characters in the resulting output string. Must be 1 or greater.

outstring - Alphanumeric
Is the resulting output string after all replacements and padding.


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Expert
posted Hide Post
Using Sean's example -

-SET &FIELD = '"abc"def"ghi"';
-SET &NewFld = STRREP (&FIELD.LENGTH, '&FIELD.EVAL', 1, '"', 3, '%22', 40, 'A40');

-TYPE &FIELD
-TYPE &NewFld


Gives the output

"abc"def"ghi"
%22abc%22def%22ghi%22

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Expert
posted Hide Post
STRREP must be a much-needed new function in 7
7 rocks!!




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Platinum Member
posted Hide Post
Tony,

Nice to see that IBI has introduced a function to handle this job!

I'm stuck with 5.2.x for now, so I'll have to keep the hand-coded method until we move to 7.

Thanks,
Sean


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
 
Posts: 210 | Location: Ottawa | Registered: November 03, 2005Report This Post
Silver Member
posted Hide Post
ah ha! that STRREP function would have saved me a lot of work over the last two days. byebye 50 lines of code.

This message has been edited. Last edited by: GreenspanDan,
 
Posts: 41 | Registered: August 05, 2005Report This Post
Guru
posted Hide Post
Must the replacement value eq %22? Are the double quotes a result of saving or holding the file in format lotus?


Glenda

In FOCUS Since 1990
Production 8.2 Windows
 
Posts: 301 | Location: Galveston, Texas | Registered: July 07, 2004Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     convert double quote to "%22"

Copyright © 1996-2020 Information Builders