Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3695

How to split a string into an array of words that ignores text direction

$
0
0

I have method that splits a string into words and then draws those words, one at a time, in a listbox CellTextPaint event. Like

var s as string = "Hello World"
var a() as string = s.split(" ")
//a(0) = "Hello"; a(1) = "World"

When I do the same with a RTL language, such as Hebrew, the “second” word (second from the left) is now at index 0

var s as string = "קךךם רךג"
var a() as string = s.split(" ")
//a(0) = "קךךם"; a(1) = "רךג"

I understand that there is some logic behind this, but it defeats the purpose of the method. I don’t care about the correct lexical order, just the left-to-right order. Unfortunately, I can’t roll my own split() because all string functions, like left, mid, Nthfield, etc., start counting from the right.

I know that I could do a reverse sort on the string array, but that assumes I know that the string is in a RTL language, which I don’t (the text can come from anywhere).

I’ve tried setting the string encoding to ASCII or even nil and performing a SplitBytes(), but that doesn’t give the LTR values, either.

Can something think of an elegant way to get Xojo (with or without MBS) to return an array of words that uses the LTR orger and ignores the lexical text direction?

11 posts - 5 participants

Read full topic


Viewing all articles
Browse latest Browse all 3695

Trending Articles