iOS \t (tab character) not displaying correctly - ios

When I try to add tab white spaces to my UILabel text in Arabic, it seems not working, while in english it's working ok:
English : (_ means white space)
col1\tcol2\tcol3\t >>>
COL1ــــCOL2ــــCOL3
Arabic
لغة۱\tلغة۲\tلغة۳ >>>
لغة۱لغة۲لغة۳

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.

QML Text objects missing spaces after commas or periods in iOS 14

With QML based applications iOS 14 - for any Text elements that contain a space following a comma or period - the space does not appear. Has anyone else run into this?
If I change the text to be two spaces after a comma, then a single space does appear in v14 but appears as two spaces in v12 & v13 (only the first space after a period or comma is lost).
In the image below the left-hand side shows a simulation in iOS 12.1 where the spaces appear normal, the right-hand side shows a simulation in iOS 14.0 where the spaces go missing. iOS 13.7 (not pictured) appears similar to v12.1.
import QtQuick 2.12
import QtQuick.Window 2.12
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Text {
id: textID
text: qsTr("I, am, some. text. Here. Is a double space.")
}
}
Qt: v5.15.0
XCode: v12.0.1
MacOS: Catalina v10.15.7

Font Width is Different

apple 0.31414 (Label1)
banana 0.41253 (Label2)
kiwi 0.2312 (Label3)
On iOS, however, the width of a single letter is not uniform, as in this case(Editor, not this screen). It is different when it is in uppercase or lowercase, and when it is 0 or 1. I want to do the beginning of the text and the beginning of the number at the same position.
I tested it with several built-in fonts on iOS, but I could not match the position of letters and numbers.

How do I split a string with white space in Google Sheet that include white space in output

I have the following string :
A||B| |C||||| | and I want the following output A|.|B|.|C|.|.|.|.|.|
When I'm doing this =SUBSTITUTE("A||B| |C||||| |","||","|.|") I have the following output A|.|B| |C|.||.|| |. why not all the space between | are filled with • ?
The main idea behind this is to replace each white space with a specific character so I can use the Split function (which doesn't output white space otherwise)
It's because there's no white space between ||. It's just two consecutive | . Sometimes there's white space. Other times, there's none.
This will give your desired output:
=SUBSTITUTE(trim(REGEXREPLACE(REGEXREPLACE("A||B| |C||||| |","(\|)","|•"),"(•)(\w)","$2"))," ","")
Please try:
=REGEXREPLACE(REGEXREPLACE(A1," ?(\|)",".$1"),"([A-Z]+)\.","$1")
or
=REGEXREPLACE(REGEXREPLACE(A1," ?(\|)",".$1"),"(\w+)\.","$1")
where A1 = A||B| |C||||| |

How to achieve UILabel line breaks only on a specific separator character?

I have a string which has a separator character between words (Words with spaces) eg.
"Male • 89 • Senior Citizen • Side Lower Berth • Non Veg • Bedroll"
So "•" is separator here. Now while assigning it to a multiline label I want line breaks only on this separator. Eg. I don't want line breaks in between "Side Lower Berth" so that some part of it rendered in the first line and remaining one in next line. It should draw it next line only by making the decision based on the defined separator "•" here.
Try replacing all of your ordinary spaces with nonbreaking spaces, except in the places where you want to allow that break the line. (So leave an ordinary space after each bullet)
What if you jump lines when • appears? If you wanna try :
yourString.replacingOccurrences(of: "•", with: "\n")
I don't know if that's what you want, if not, sorry.

Resources