LOGICALな文章を、VISUALに表示するためのプログラムを示します。
双方向アルゴリズムや、その元ネタのhttp://www.unicode.org/unicode/reports/tr9/を元に、perl scriptを起こしてみました(かなり簡略化しています)。
このファイル名をhtrans.plとした場合、使用方法です(perl5以上で確かめました)。
perl htrans.pl stdin < xxxxx.txt
このxxxxx.txtは、LOGICALな文章を保管しているファイルです。
ないしは、packageとして使用できます。
require 'htrans.pl';
$out=&htrans'htrans($intext,$edir,$mode,$fcou);
INPUTs
$intext : input text
$edir : default direction, L is left-to-right,
R or others is/are right-to-left
$mode : reserved (it'll be, VtoL is Visual to Losical,
LtoV or others is/are Logical to Visual)
$fcou : reserved (folding charactor count)
OUTPUT
$out : output text
これがhtrans.plのソースです。