Home > OS >  How to show mixed english and persian text correctly in android?
How to show mixed english and persian text correctly in android?

Time:11-03

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.

CodePudding user response:

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)
}
  • Related