NASRIN
NASRIN

Reputation: 499

Why is it not rtl?

My program creates a message in Persian language that it have time like 12:00 or 12:45. I want show this message to user. This message in html view haven't correct format.

The problem is that the times is like : 54:12 or 00:12 .

How can I change the format??

for (int j = 1; j < time[i].Count; j++)
{
    msg4SmsPart2 += countPoll.ToString() + ". " + date + " " + time[i][j] + " ";
}

tim[i][j] is my time like : 12:00 , 12:45, ....

Final message is : 1. 1392/9/27 12 :45 2. 1392/9/27 13 :37 3. 1392/9/28 13 :50 4. 1392/9/28 10 : 00 - 12 : 00 .

but in my site all times is revers : 1. 1392/9/27 45 :12 2. 1392/9/27 37 :13 3. 1392/9/28 50 :13 4. 1392/9/28 00 : 10 - 12 : 00

When I test this code:

for (int j = 1; j < time[i].Count; j++)
                {
                    msg2times += countPoll.ToString() + ". " + date + " " + time[i][j] + " ";

                }

Format of msg2times is correct but when I add a sentence in Persian language, it's incorreect!

msg4SmsPart2 += msg2times;

Upvotes: 1

Views: 106

Answers (3)

user.dz
user.dz

Reputation: 1032

It could be a problem of Unicode-BiDi control, So you can give it a try by:

Adding

U+202A:   LEFT-TO-RIGHT EMBEDDING (LRE)

control character just before the time and

U+202C:   POP DIRECTIONAL FORMATTING (PDF)

just after it.

See Unicode controls vs. markup for bidi support

Upvotes: 1

SpiderCode
SpiderCode

Reputation: 10122

This will do the trick :

for (int j = 1; j < time[i].Count; j++)
{
    var time = string.Empty;
    if (time[i][j] != null)
    {
        time = (Convert.ToDateTime(time[i][j])).ToString("hh:mm");
    }

    msg4SmsPart2 += countPoll.ToString() + ". " + date + " " + time[i][j] + " ";
}

Upvotes: 1

Ramesh Rajendran
Ramesh Rajendran

Reputation: 38663

try this

          for (int j = 1; j < time[i].Count; j++)
            {
                msg4SmsPart2 = countPoll.ToString() + ". " + date + " " + time[i][j] + " ";
                msg4SmsPart2 += msg4SmsPart2.ToString("HH:mm:ss");//formating for time 
            }

Upvotes: 1

Related Questions