So I'm looking to split a long string into array elements, and each element in the array can only be a maximum of x characters long.
Sounds simple enough, right?
But here's the tricky part:
I also don't want it to break up words. So it wouldn't start a new line just in the middle of a word awkwardly li
ke this.
And it also should respect newlines that were in the string already.
For an example, this thing that I am writing right now needs to be split into multiple lines, and lets say each line can be a maximum of 80 characters. So I'm going to do this manually, look below this block of text to see what I mean. Also, just to spice things up I'mWritingLikeThisJustToMakeSureThatItWouldHandleSpecialStuffAswell. ║ ┘ some special characters here as well §§§ § § § ╬ ²„² „„ ²„„ ®®® ®¾ ¾¾ ¾ test ∟¡æ◙ hel&&lo((( and here
are some
new lines, it should
respect these
aswell.
Code: Select all
For an example, this thing that I am writing right now needs to be split into ; 77 chars
multiple lines, and lets say each line can be a maximum of 80 characters. So ; 76 chars
I'm going to do this manually, look below this block of text to see what I ; 74 chars
mean. Also, just to spice things up ; 35 chars
I'mWritingLikeThisJustToMakeSureThatItWouldHandleSpecialStuffAswell. ║ ┘ some ; 77 chars
special characters here as well §§§ § § § ╬ ²„² „„ ²„„ ®®® ®¾ ¾¾ ¾ ; 78 chars (yes, empty spaces, they didn't show up outside of the codeblock :L)
test ∟¡æ◙ hel&&lo((( and here ; 29 chars
are some ; 8 chars
; 0 chars
new lines, it should ; 20 chars
respect these ; 13 chars
aswell. ; 7 chars
But in my case I actually wouldn't be using these line breaking characters. The empty line that I marked to have 0 characters would just literally be empty.
An empty element in my array, and not consist of \n or \n\r, or whatever.
Also note that a useless empty space at the end of a line doesn't need to be preserved. It'll be of no use for me.
So yeah, I'm just having trouble implementing this logic with the AHK language.
Any help is highly appreciated,
Thanks.