emacs-bidi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [emacs-bidi] bidi categories


From: Alex Schroeder
Subject: Re: [emacs-bidi] bidi categories
Date: Tue, 13 Nov 2001 16:47:10 +0100
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1 (i686-pc-linux-gnu)

"Ehud Karni" <address@hidden> writes:

> Try for example (capital means strong R [Hebrew] as usual) the
> following visual text "ABCD 1234 abcde 5678 EFGH".
> With LRM (symbolized by ^) it is represented logically by:
> In right-to-left reading direction - "HGFE^ 1234 abcde 5678 ^DCBA"            
>               
> In left-to-right reading direction - "DCBA^ 1234 abcde 5678 ^HGFE"   
> without formatting characters it is impossible.

Ok, I am still a but unclear on your idea.  The above passage shows me
where LRM will be in the logical representation, but I cannot deduce
where you would have added it in the visual text (before applying the
usual algorithm).

What I did, then, was this: I added the LRM at the end of every
sequence of R types before applying the algorithm.  Is this a possible
interpretation of what you were saying?

Alex.

;; This is the problem:

(bidi-visual-to-logical "ABCD 1234 abcde 5678 EFGH" 'L2R)
"1234 DCBA abcde 5678 HGFE"

;; It cannot be reversed:

(bidi-logical-to-visual
 (bidi-visual-to-logical "ABCD 1234 abcde 5678 EFGH" 'L2R)
 'L2R)
"1234 ABCD abcde 5678 EFGH"

;; Try adding LRM:

(defvar bidi-lrm (decode-char 'ucs ?\x200E))
(defun bidi-strip-lrm (str)
  (apply 'concat
         (split-string str (char-to-string bidi-lrm))))

;; Problem solved?

(bidi-strip-lrm
 (bidi-visual-to-logical 
  (format "ABCD%c 1234 abcde 5678 EFGH%c" bidi-lrm bidi-lrm)
  'L2R))
"DCBA 1234 abcde 5678 HGFE"

;; And it can be reversed if we don't strip LRM immediately.

(bidi-strip-lrm
 (bidi-logical-to-visual
  (bidi-visual-to-logical 
   (format "ABCD%c 1234 abcde 5678 EFGH%c" bidi-lrm bidi-lrm)
   'L2R)
  'L2R))
"ABCD 1234 abcde 5678 EFGH"

-- 
http://www.emacswiki.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]