Focal Point
[SHARING] - Remove Trailing Spaces from text output (Unicode UTF-8)

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2147011196

February 14, 2019, 01:58 AM
MAK
[SHARING] - Remove Trailing Spaces from text output (Unicode UTF-8)
Hi all,

Just thought I would again share a very simple solution that I'm sure most of you know but is not well documented. Hopefully this is not a piece of useless information.

The issue was that we have a requirement to output data to a text file and ensure that there are x number of spaces at the end of each row.

The row in the Oracle Database is set to A2000V however the maximum length in the row is 130 Characters with spaces after that.

The text file output required was that the end of the row had 8 trailing spaces.
If using a codepage like 1252 then you can set a define field to A138 and the output is fine.

However if using UNICODE the multiplication factor that accounts for the maximum of 3 Bytes will basically triple the space which in our case was adding 200+ spaces in the text file. (Even though it's not really space but bytes)

Anyway what we had to do was stipulate to WebFOCUS the number of bytes to display.
This was done by changing the define field from

DEFINE FILE REPORT_DATA
DF_MERGE_COLUMN/A138 = MERGE_COLUMN

to

DEFINE FILE REPORT_DATA
DF_MERGE_COLUMN/A138B = MERGE_COLUMN

Adding the B at the end of the field length in the define allowed us to have a text file with the correct number of spaces.


WebFOCUS 8203M
O/S Windows 7
February 14, 2019, 08:15 AM
Addy
Cool,
Thanks for sharing

Nice Thread


WF 8.2.04
Windows/Unix
All Formats
In Focus since 2006
February 15, 2019, 05:52 PM
MathematicalRob
I didn't know that, but wish I had; thank you!


WebFocus 8201m on Windows; App Studio 8201; Procedures: WebFocus with SQL; HTML Parameter Pages & Dashboard; Output: Excel, HTML, & PDF.
February 15, 2019, 06:30 PM
MathematicalRob
However, when I do get a multibyte character in one of my fields, if I use this approach, my field ends up being too narrow, and my next field starts early.

If anybody has a solution to that, I'd love to hear it! One could convert all multibyte characters to ASCII characters at the outset, but that seems uneccessary in 2019. . .


WebFocus 8201m on Windows; App Studio 8201; Procedures: WebFocus with SQL; HTML Parameter Pages & Dashboard; Output: Excel, HTML, & PDF.
February 16, 2019, 06:40 PM
MAK
Can you give me an example of how your data is structured? Specifically where your Multibyte character is.
I haven’t tried this with a blend of ASCII and Multibyte but as we output Chinese Characters I can quite easily create a data source that does this.


WebFOCUS 8203M
O/S Windows 7