Dear Mr. Brauer et al:
I am a priest in our religion, Zoroastrianism (Zarathushtri). Our religion 
is one of the oldest and was the state religion og Iran (Persia) from Cyrus The 
Great in 4th century BC to almost 630 AD. Cyrus, as you may know, released the 
Jews from Nebuchadnezzar in Babylon.
Our scripture language is called Avesta and it is written, like Hebrew, 
from right to left. I am interested in R2L and BIDI technologies but am quite a 
novice in both of them.
 
One of my friends directed me to your 2 year old message shown below:
 
=====================
Hi 
quite a while ago, I asked about the possibility of having TRUE 
R2L
(or BIDI) support for Hebrew or any other R2L language with in
Mule. 
However it turned out that, while there will be or is a
rewritten display 
engine for GNU emacs (20.5), to rewrite the display
engine for xemacs is far 
more complicated and will not be done any
time soon.
Now I have a 
relatively simple question, which has nothing to do with
Mule, the iso-8859-8 
is sufficient for my purpose: The basic primitive
idea is to write text with 
iso-885908 characters but L2R.
(The idea to have the cursor at the right and 
putting it to the left
visual mode) causes more problem than 
benefits)
However for TeX purpose the text has to be converted.
In the 
following sense:
Invert the order of words in a given
line and the order 
of the letter in a given word.: Example
Hello word.
gives
.drow 
olleH
For example the following will do it:
(defun 
ivrit-revers-region (arg) 
"Does the same as ivrit-revers-buffer but 
only in marked regions" 
  (interactive "p") 
  (if (or (and
	   (boundp 'zmacs-region-active-p) 
zmacs-region-active-p)
	  (and (boundp 'transient-mark-mode) 
transient-mark-mode mark-active))
      
(save-restriction
        
(save-excursion
          
(narrow-to-region (point) (mark)) ;new finish here1
	  (goto-char 
(point-min))
	  (let ((begl 0)(endl 0)(not-end 
t))
	    (while not-end
	      
(setq begl (point))
	      
(end-of-line)
	      (setq endl 
(point))
	      (if (/= begl endl)
		  (let 
((str (buffer-substring begl endl)))
		    (kill-region begl 
endl)
		    (insert (revers-string 
str))))
      (setq not-end (eq (forward-line 1) 
0))))))))
(defun revers-string (str)
(interactive)
  (if 
(< (length str) 2)
    str
    
(concat (revers-string (substring str 1)) (substring str 0 1))))
Or 
another possibility (given to me by Ehud Karni) is 
(defun invert-line 
(&optional arg)
"Inverse line (right-left) if arg given, 
inverse arg chars"
  (interactive 
"p")
       (let* ((pos 
(point))
              
(eos (progn (if (< arg 
2)
                              
(end-of-line) (goto-col (1+ arg))) 
(point)))
              
(str (buffer-substring (progn (beginning-of-line) (point)) 
eos)))
           
(insert-string (invert-string 
str))
           
(delete-char (length 
str))
           (goto-char 
pos)))
(defun invert-all-lines (&optional 
arg)
"Invert (right-left) all the lines in the buffer,
if arg 
given, inverse arg characters in each lines"
  (interactive 
"p")
       (goto-char 
(point-min))
       (let* ((eol 
0)
              
(bol 
0)
              
(str 
""))
           
(while (not 
(eobp))
               
(setq bol 
(point))
               
(end-of-line)
               
(if 
arg
                   
(goto-col 
arg)
                   
(end-of-line))
               
(setq eol 
(point))
               
(setq str (buffer-substring bol 
eol))
               
(delete-region bol 
eol)
               
(insert-string (invert-string 
str))
               
(forward-line 1))))
(defun invert-string (STR)
"Invert 
STRING (right-left) of any 
length"
       (invert-sub-string 0 
(length STR))  ;invert the whole 
string
       STR)
Anyhow my 
question is simple but may be the answer is not so simple.
It is possible to 
modify these functions such that the only applies for
strings which have at 
least 2 characters however all the characters
have to be in the octal 
representation > 127. That would mean that
ASCII text remains 
unchanged but Hebrew text, > 127 will be changed.
The function 
iso-unaccentuate does precisely this, ie changes only
characters above 127. I 
tried to modify the reverse functions
mentioned above accordingly, but 
without success. 
Does anybody has an idea?
Thanks in 
advance
===========================================
The code suggested is exactly what I need to incorporate.
 
My objective is to do the following:
1. we have a large number of English transliteration of our scriptures 
available in Internet but not in our original language Avesta.
2. I would like to use these transliterations in English from left to right 
and invert them as you suggest in your message above word by word first within a 
para and then letter by letter within a word. For instance, per your above 
message:
 
Hello Word.
 
becomes
 
.droW olleH
 
3. If I can do this, then I copy the inverted transliteration in a Word 
document, select all and change the font from say Arial to Avesta and I will 
have a first cut of the whole page into Avesta which then I will have to edit 
for the final Avesta document.
 
Questions to you or anyone who can help us:
1. How can I use this code? I am familiar with Microsoft Visual Basic in 
Excel or Access and can use a subroutine in a cell in Excel or a text box in 
Access to take as argument a page of the transliteration and invert it with your 
code.
2. Is this code in your message will work in Visual Basic?
3. Can you suggest a better way to do so. We have documents and documents 
to invert.
4. If not, can you suggest someone else who can help us?
5. I have Windows XP Professional. Does Microsoft has any support like this 
in Windows?
 
First of all, I am not sure if I am sending this to the correct 
people. If not, please accept my sincere apologies. And if so, could you please 
forward this message to the right people.
 
This help will be a big step forward for us in our research.
 
Thanking you in advance, 
Soli P. Dastur, Sarasota, Florida, USA