2

I have a file name like 12343.mp4 and I want to show this text inside of a Persian text. For example I want to show something like this:

enter image description here

But what I get is like this:

enter image description here

As you can see the .mp4 part goes to the start of the file name instead of end of it.

This is my code:

 fun main() {
    val fileName = "12343.mp4"
    val text = "دانلود فایل $fileName تمام شد."
    println(text)
}

Is it possible to fix this problem? Thanks.

Hadi
  • 544
  • 1
  • 8
  • 28
  • 1
    Have you seen: [Android mixed language text - BidiFormatter on String with RTL and LTR text](https://stackoverflow.com/q/20473657/295004), [How mixing LTR and RTL languages is managed in unicode?](https://stackoverflow.com/q/4989346/295004), [Android Hebrew (RTL) Integration](https://stackoverflow.com/q/10975176/295004) – Morrison Chang Oct 31 '21 at 20:25
  • @MorrisonChang Yes. I've tested it. But it didn't make any difference in my example and texts were the same. – Hadi Oct 31 '21 at 20:47
  • You should show what you've tried with detail. Your example code is rendering with plain `println` while you've tagged this question `android`. – Morrison Chang Oct 31 '21 at 21:13
  • @MorrisonChang for the sake of simplification i just posted the simplest code. I don't know that if `BidiFormatter` is used for this kind of texts or not and because of that I didn't share android code. – Hadi Oct 31 '21 at 23:04

1 Answers1

0

Thanks to (Morrison Chang) for his comment.

As Ted explains in this question I just had to surround the name of the file with ‎‎\u200e character. So the code should look like this:

fun main() {
    val fileName = "12343.mp4"
    val seperator = "\u200e"
    val text = "دانلود فایل " + seperator + fileName + seperator + " تمام شد."
    println(text)
}
Hadi
  • 544
  • 1
  • 8
  • 28