iText Chinese punctuation at the beginning of line - itext

Do you know how to resolve the problem when one line is full, then the Chinese punctuations will be placed at the beginning of next line as shown in (1)? In fact we hope the punctuations to be placed at the end of each line as shown in (2).
(1)
你好你好
,你好你好
(2)
你好你好,
你好你好
Thank you very much for your help in advance!

You are placing a space between the last char and the punctuation and that is a split point. The simplest way is to remove the space before the puntuation and add it after. Other option is to replace the space with a non breaking space \u00a0 to avoid the split at that point.

Related

Prevent newline in (.md) files

How do I prevent newlines in the readme.md files (GitHub)?
We can always write the whole thing in one line to prevent it. But is there an exclusive tag/option to prevent the same, especially for tags that create newlines (headings) like span in html?
Doesn't a space followed by a backslash do the concatenation you want? It does for me. That way I can break a paragraph into one sentence per line.

Save UITextView String With \n Instead of Line Breaks (Swift)

I have a UITextView in my Swift app in which users can input text. They can input text with as many line breaks as they like but I need to save the string with the newline command (\n). How would I do this?
For example, my user inputs
Line 1
Line 2
Line 3
in the UITextView. If I was to retrieve the string...
let string = textview.text!
this would return
"Line 1
Line 2
Line 3"
when I would like for it to return
"Line1\nLine2\nLine3"
How would I go about doing this? Can I use a form of replacingOccurrences(of:with:)? I feel like I'm missing a fairly obvious solution...
Eureka! After WAY too much research and learning all about String escapes, I found a very simple solution. I'm quite surprised that this isn't an answer out there already (as far as I can tell haha) so hopefully, this helps someone!
It's actually quite simple and this will work of any String you could be using.
textView.text!.replacingOccurrences(of: "\n", with: "\\n")
Explanation:
Ok so as you can tell, it's quite simple. We want to replace the newline command \n with the string "\n". The problem is that if we replace \n with \n, it's just going to transfer over to a newline, not a string. This is why escapes are so important. As you can see, I am replacing \n with \\n. By adding an extra \ we escape the command \n entirely which turns it into a string.
I hope this helps someone! Have a great day!
Have you tried replacing \r with \n? or even \r\n with \n?
I hope I am not making an obvious assumption you considered, but maybe this may come in handy:
Is a new line = \n OR \r\n?

Flex: easy way to see if a line has any content?

Among many rules in my Altair BASIC Flex file is this one:
[\n]
{
++num_lines;
++num_statements;
return '\n';
}
++statements; is not actually correct - in theory the line might be empty (due to bad data in the .BAS file for instance) and thus not have any statements on that line. So is there any way to know if there's any tokens in front of the \n since the last \n? I know you can do this with the BEGIN() et all, but that seems like a LOT of work for a simple problem! Is there an easier way?
It's easy to match a blank line, although I'm not sure that's really what you're looking for.
The first pattern matches a line which only contains space and tab characters (adjust as necessary to match other whitespace). The second pattern matches the same whitespace when it's not at the beginning of a line. (Actually, it would match the whitespace anywhere, but at the beginning of a line, the first pattern wins.)
^[ \t]*\n ;
[ \t]*\n { ++num_statements; return '\n'; }
Instead of counting lines yourself, I suggest you use %option yylineno so flex will count them for you. (In yylineno.)

eclipse How can I define how many spaces the IDE uses when it autocomplete?

I lose a lot of time putting right amount of spaces in my code, going back and forward with cursor, for it to look exactly the way I like it... example:
identifier space assignmentOperator
space someFunction space leftParenthesis
space argument space rightParenthesis space semicolon
code example:
char character = JOptionPane.showInputDialog( "Introduce the
character that is gonna draw the rectangle" ).charAt ( 0 ) ;
This way everything looks a lot better to me, but when eclipse autocompletes it doesn't use any of those spaces, so I have to put them by hand.
There is actually quite a lot to see here:
http://www.wikihow.com/Change-the-Default-Format-Settings-in-Eclipse

IText Paragraph preposition line breaks

When creating long Paragraph with ALIGN_JUSTIFIED mine text has some "language grammar volations" which are very annoying for mine customer. Such volations occurs when line ends on single character like: 'o', 'i', etc. They are called preposition I guess. Those characters should be moved to next line and next line should start from them. The problem is I do not know if they occurs on the end or in the middle. Maybe someone will give me hint how to solve this ?
Please imagine that those two below examples are justified but they have line breaks in different place.
NOT OK:
Demonstracja problemu z
bekartami
OK (desired):
Demonstracja problemu
z bekartami
This should be solved by using a non-breaking space.
Instead of using a String "z bekartami", you should use a String "z/u00a0bekartami".
This will solve your problem.