R to trim the space - cobol

When I passing empty input I have to get no space in delimiter || like this. but I am gitting 1 length space | |. how to remove this space in COBOL.
ALPHANUMERIC MOVE, RECEIPT-NO
IF WSCLMLO-RECEIPT-NO EQUAL SPACE OR LOW-VALUES
MOVE CZ-1 TO WS-S1
ELSE
SET VALID-DATA-NOT-FND TO TRUE
MOVE SPACES TO WS-FIELD-TEXT-DATA
MOVE ZEROES TO WS-FIELD-LENGTH
MOVE CZ-13 TO WS-FIELD-LENGTH
MOVE WSCLMLO-RECEIPT-NO TO WS-FIELD-TEXT-DATA
PERFORM X20-CALC-TEXT-DATA-LENGTH
MOVE WS-DATA-POS TO WS-S1
MOVE WS-DATA-LENGTH TO WS-E1
END-IF
MOVE WMATRANI-BSB-NO TO WSCLMLO-BSB-NUMBER
MOVE WMATRANI-ACCOUNT-NO TO WSCLMLO-ACCOUNT-NO

Related

Weird behaviour on joining mixed right-to-left and left-to-right language strings

Input:
tempTextArray:
▿ 3 elements
- 0 : "זה מבחן"
- 1 : "7 x 5 abc"
- 2 : "other text"
When doing a simple tempText = tempTextArray.joined(" | ") the result is not placing all elements where I'd expect them... result:
Printing description of tempText:
"זזה מבחן | 7 x 5 abc | other text"
its my first time combining right-to-left with left-to-right texts, has anyone dealt with a similar situation before?
My app is receiving translations from backend, so I don't know what elements are translated to (in this case) Hebrew, and which I will receive in my default language (English)
This is caused by the Unicode BIDI (Bidirectional Text) algorithm. First, I'll explain how to fix it, since it's fairly straightforward, then I'll explain what's happening in case you want more information.
You need to add LTR (Left-To-Right Mark) characters at each place you want to reset the text direction to be LTR. In your case that's at the start of the string and at the start of each | block:
let ltr = "\u{200e}"
let tempText = ltr + tempTextArray.joined(separator: "\(ltr) | ")
// => ‎זה מבחן‎ | 7 x 5 abc‎ | other text
If you're going to do work with Hebrew, you absolutely want to read Cal Henderson's fantastic explanation of the algorithm: Understanding Bidirectional (BIDI) Text in Unicode.
Now to explain what's happening. You're printing a single string whose first character is the ז in "זה מבחן," and last character is the final t in "text." It is not three strings separated by |, it's just one long string. When you display that string, and the BIDI algorithm has to decide where all the characters go.
The first character (ז) is a RTL character, so it decides that this is a RTL string that has some LTR text embedded. That's the opposite of what you want. You want this to be a LTR string with some RTL text embedded. So you need to start with a LTR character such as Left-To-Right Mark.
The BIDI algorithm's job is to tell the system in which direction the next character should go. Each of the characters in זה are RTL, so that's easy, keep going left. But what about the space between זה and מבחן? Space is neutral in direction, and the last character was RTL, so the space goes to the left. But then we come to the space between מבחן and |. Space is neutral and | is neutral, so the BIDI algorithm would put the space and | to the left again. You want the space and | to be LTR, so you need to add another LTR character there.
7 is also neutral, but x is LATIN SMALL LETTER X which is LTR (not MULTIPLICATION X which is neutral).
The final result is that the BIDI algorithm decides this is a RTL string that begins 7 | זה מבחן and then is followed (to the left) by an embedded LTR string x 5 abc | other text. (In other words, this is a Hebrew string that happens to have some English in it, not an English string that happens to have some Hebrew.)
I expect what's actually displayed in your question above isn't what you're seeing (because of how BIDI algorithms get applied on Stack Overflow). I expect it actually looks like this:
And if you read this right to left, it should make more sense now what's happening.

Spacemacs yellow line

I am a novice when use Spacemacs. when edit c++ files. there are yellow highlight lines. so I want to disable the yellow highlight and what does the yellow hightlight means?
The yellow highlights are whitespace. If you do not want whitespace to show you can add (setq show-trailing-whitespace nil) to the dotspacemacs/user-config section in your .spacemacs (open with SPC f e d and reload with SPC f e R).
I prefer to keep the whitespace highlighting enabled and remove trailing whitespace automatically. This can be done by changing the variable dotspacemacs-whitespace-cleanup in dotspacemacs/init to 'all, 'trailing or 'changed.

Strip whitespace in a UITextRange

I am working with a UITextView and am trying to programmatically change the selection so that it contains no leading or trailing whitespace, akin to String.trimmingCharacters(in: .whitespace).
My approach would be to locate the outermost non-whitespace characters within the region, and then have the appropriate checks to make sure that the region is not empty or reversed. (But I have no idea how to go about this.)
textView.selectedTextRange = textView.textRange(from: 'position of first non-whitespace character after textRange.start',
to: 'position of first non-whitespace character before textRange.end')
Or perhaps there is a better approach, maybe using the UITextView’s tokenizer? In fact, the original selection range that I am trying to strip is acquired by
textView.tokenizer.rangeEnclosingPosition(position, with: .paragraph, inDirection: UITextLayoutDirection.left.rawValue)
however I don't want the trailing newline engulfed by UITextGranularity.paragraph to be included in the range.

How can I draw only one char of a string, without moving its position?

I have a string : School
i'm trying to have only 1 letter of this string to show in a different color, and move this letter back and forth.
this works somewhat ; I use a string(index) and move the index with a timer, than draw the 2nd string ("S", " c", " h", etc ) on top of the 1st.
my problem is that I cannot stack those 2 string exactly ... the space isnt the same size as the other characters.
moving orange letter
I guess I could use a Font.measureString from the part of the string "School" I want to skip, and move my orange letter according to it and tweek it depending of each letters ... but it seems a tedious way of doing this...
Is there a simpler/ better! way to do it ?

Align UITextView Right and Left.

I have UITextView, which is left aligned.
When last word does not fit on current line it goes to next line leaving spaces on end of line.
which does not give good look and feel.
So, what I want that if words of particular line feels the spaces left at end.
i.e. Spaces between two words can dynamically varies.
Here I am giving example of Scenario:
The width of text view,never put off until (here tomorrow does not fit,so it goes to next line leaving spaces).
Tomorrow what you can avoid all together.
So, problem is it does look good.
What I want is:
The width of text view never put off, until (varying spaces shown by)
tomorrow -what -you -can
avoid --all -- together.
Thanks in Advance.
There is no setting for justified aligment for text you only have center, left and right. If you want justified aligment where every line has the same amount of characters or something like that you can format the text entered to have carriage returns after x amount of characters or words, or something like that.

Resources