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     [CLOSED] how to convert ASCII code back to printable characters?

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] how to convert ASCII code back to printable characters?
 Login/Join
 
Member
posted
hi, i am receiving a string which contains ASCII codes i want to convert them back to printable chars, is there any function in weFocus to do so?

thanks

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


WebFOCUS 8
Windows, All Outputs
 
Posts: 1 | Registered: August 07, 2016Report This Post
Master
posted Hide Post
Did you not try STRREP?

If you are trying to change a non-printable character to a printable one, you may want to use the HEXBYT function to set the unprintable character to a variable name.

If you are on Linux or Unix you can use the sed command as well.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006Report This Post
Virtuoso
posted Hide Post
Do you mean to say that your string contains hexadecimal pairs of numeric ASCII codes? Or decimal triplets perhaps?

You would have to start with splitting up the string into individual pairs (or triplets). The easiest approach is with -REPEAT ... WHILE ...
Within the loop you can decode the ASCII code to a character and concatenate it to a string.


An alternative approach is to us a TABLE request with an enumeration based on a COMPUTE with LAST. For that to work, you need to "generate" records into your source table so that the number of rows matches the number of ASCII codes in your input string. The usual approach to that is to JOIN the table against a sequence of the correct length - MacGyver does the trick.

For decoding the ASCII character, you'll have to cut a substring out of the input string based on that enumeration and the ASCII code length and then you can decode it.

Concatenate the result of the above to another field using LAST again. Finally, only retrieve the final record of that TABLE.

That gets complicated, doesn't it? Smiler


Or... you can perform the decoding in PASSTHRU SQL, using a recursive CTE if your RDBMS supports those.
In case you're using PostgreSQL, you could also use the convenient generate_series() function to create a table of sorts. Then you do the conversion per row per ASCII code and aggregate the whole thing together again with another function.

The approach here is actually quite similar to the FOCUS approach, but a little less difficult to implement.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Virtuoso
posted Hide Post
Hi Masoud,
quote:
i am receiving a string which contains ASCII codes i want to convert them back to printable chars

Questions:
"receiving a string" - how? from where?
"ASCII codes" - what type of codes? control characters such as CR, LF? non-printing characters such as HEX A0?
"convert BACK - back to what?

With some answers we can go forward.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1980 | Location: Tel Aviv, Israel | Registered: March 23, 2006Report 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     [CLOSED] how to convert ASCII code back to printable characters?

Copyright © 1996-2020 Information Builders