Page 1 of 2
aligning text in right-to-left languages
Posted: Tue Sep 21, 2004 1:18 pm
by newmember
i have a div where i dynamicly(with php) load text.
the thing is that this text might be hebrew and it will be displayed aligned to left.
what i mean is that it is pointless to set text direction for div because sometimes it will be left-to-right text and sometimes right-to-left text...
i don't really know what to do

Posted: Tue Sep 21, 2004 1:23 pm
by Joe
Am I right in saying that you wish for text to be aligned in the position you wish?. If so try the good old pre tags.
Posted: Tue Sep 21, 2004 1:47 pm
by feyd
if you know the content needs left-to-right then set that direction, same for right-to-left... what's the big deal?
Posted: Tue Sep 21, 2004 2:02 pm
by kettle_drum
Why not justify you text? Will look the same then whatever direction the text reads in.
Posted: Tue Sep 21, 2004 2:16 pm
by newmember
feyd:
i don't know whether the content is hebrew or english
Why not justify you text?
i tried it with no luck...in css docs it is said:
Conforming user agents may interpret the value 'justify' as 'left' or 'right', depending on whether the element's default writing direction is left-to-right or right-to-left, respectively.
- so it depends on what ua decides
Am I right in saying that you wish for text to be aligned in the position you wish?.
no i'm not forcing text to align to some specific position...
the text is inside <p>. that's all.
Posted: Tue Sep 21, 2004 2:18 pm
by Weirdan
Are you talking about visual align or text direction?
By 'visual align' I mean:
RTL hebrew aligned to the left:
Code: Select all
Margins
|< -------------------->|
|WERBEH WERBEH |
|WERBEH |
|WERBEH WERBEH |
RTL hebrew aligned to the right
Code: Select all
Margins
|< -------------------->|
| WERBEH WERBEH|
| WERBEH|
| WERBEH WERBEH|
and by 'direction' I mean:
LTR hebrew aligned to the left:
Code: Select all
Margins
|< -------------------->|
|HEBREW HEBREW |
|HEBREW |
|HEBREW HEBREW |
LTR hebrew aligned to the right
Code: Select all
Margins
|< -------------------->|
| HEBREW HEBREW|
| HEBREW|
| HEBREW HEBREW|
Please clarify.
Posted: Tue Sep 21, 2004 2:18 pm
by feyd
if you analyzed the utf-8 byte stream, you would know what's in it.
Posted: Tue Sep 21, 2004 2:26 pm
by Weirdan
analyzed statistically, I'd say. Because languages do share some characters, for example both Russian and English use Arabic digits
Posted: Tue Sep 21, 2004 2:29 pm
by newmember
Weirdan:
third picture(from top) is what i have but i want it to be like in the last picture
and about two first pictures...i hope this won't happen to me:)
feyd:
i can take a few characters,convert them to unicode and check whether they fall into hebrew range?
Posted: Tue Sep 21, 2004 2:34 pm
by Weirdan
newmember wrote:Weirdan:
third picture(from top) is what i have but i want it to be like in the last picture
I believe you're talking about first and second pictures respectively (try to read them right to left, from what I know it's how hebrew texts should be read).
newmember wrote:
i can take a few characters,convert them to unicode and check whether they fall into hebrew range?
well, isn't them in unicode already?
Posted: Tue Sep 21, 2004 2:54 pm
by newmember
about pictures...
i wrote 3 and 4 picture....because i assumed that each english character is a hebrew letter...so in pictures 1 and 2 hebrew letters are mirrored...but forget it...
basicly what i have is that hebrew
direction is ok but the text itself is aligned to left instead to right...so
Are you talking about visual align or text direction?
now i see that i'm talking about
visual align
isn't them in unicode already?
mmm... sort of...
the strings are in UTF-8 and it is multibyte encoding for unicode codepoints.
so i need to take part from each byte of utf-8 character and convert/transform them to unicode 2 byte codepoint...
right?
Posted: Tue Sep 21, 2004 2:57 pm
by feyd
unicode can be 8, 16, 24, and 32 bit values... so it may be better to check what codepage the utf-8 controls are switching to..
Posted: Tue Sep 21, 2004 3:03 pm
by newmember
how do i do that?
to check what codepage the utf-8 controls are switching to
i'm not completly understand what you're saying here
i think i ssaw somewhere that php support 16 bit unicode
Posted: Tue Sep 21, 2004 3:07 pm
by feyd
either find or build a utf-8 analyzer that looks at the code pages the stream switches to.. count the number of characters in the pooled languages.. use that count to base your switch between left-to-right to right-to-left.
Posted: Tue Sep 21, 2004 3:53 pm
by newmember
i guess i'll do it later...
anyway if there is no more simple solution then it will wait until i have nothing to do more...