2011-09-15 12:19:24 +00:00
( *
The function to_braille from this unit translates a string from UTF8 chars to Braille chars.
The dictionaries were taken from http: //www.ibc.gov.br/?catid=110&blogid=1&itemid=479
and from http: //www.braillevirtual.fe.usp.br/pt/Portugues/braille.html
Copyright 2 0 1 1
2011-09-15 01:20:50 +00:00
* )
2011-09-15 13:26:03 +00:00
unit mod_braille;
2011-09-15 12:19:24 +00:00
interface
{$mode objfpc} {$H+}
uses
browsermodules, lclproc;
type
{ TBrailleBrowserModule }
TBrailleBrowserModule = class( TBrowserModule)
public
constructor Create; override ;
function HandleOnPageLoad( AInput: string ; out AOutput: string ) : Boolean ; override ;
end ;
2011-11-11 01:53:39 +00:00
function ConvertUTF8CharToBraille( Char : string ; lCharSize: integer ; OrdChar: integer ) : string ;
function ConvertUTF8TextToBraille( Text : string ) : string ;
2011-09-15 12:19:24 +00:00
function ConvertUTF8HtmlTextToBraille( AInput: string ) : string ;
implementation
2011-11-11 01:53:39 +00:00
{ type
2011-11-10 18:23:42 +00:00
dictionary = array [ 1 .. 3 2 ] of string ;
2011-09-15 12:19:24 +00:00
const
number_signal = chr( $e2 ) + chr( $a0 ) + chr( $bc ) ;
caps_signal = chr( $e2 ) + chr( $a0 ) + chr( $a8 ) ;
2011-11-10 18:23:42 +00:00
d1: dictionary = ( {!} chr( $96 ) , {"} chr( $a6 ) , {# TODO} chr( $80 ) , {(*$*)} chr( $b0 ) ,
2011-09-15 12:19:24 +00:00
{%} chr( $b8 ) + chr( $e2 ) + chr( $a0 ) + chr( $b4 ) , {&} chr( $af ) , {'} chr( $84 ) ,
{(} chr( $a3 ) + chr( $e2 ) + chr( $a0 ) + chr( $84 ) , {)} chr( $a0 ) + chr( $e2 ) + chr( $a0 ) + chr( $9c ) ,
{*} chr( $94 ) , {+} chr( $96 ) , {,} chr( $82 ) , {-} chr( $a4 ) , {.} chr( $84 ) ,
{/} chr( $90 ) + chr( $e2 ) + chr( $a0 ) + chr( $b2 ) , {0} chr( $9a ) , {1} chr( $81 ) ,
{2} chr( $83 ) , {3} chr( $89 ) , {4} chr( $99 ) , {5} chr( $91 ) , {6} chr( $8b ) ,
{7} chr( $9b ) , {8} chr( $93 ) , {9} chr( $8a ) , {:} chr( $92 ) , {;} chr( $86 ) ,
2011-11-10 18:23:42 +00:00
{<} chr( $aa ) , {=} chr( $b6 ) , {>} chr( $95 ) , {?} chr( $a2 ) , {@ TODO} chr( $80 ) ) ;
2011-09-15 12:19:24 +00:00
d2: dictionary = ( {a} chr( $81 ) , {b} chr( $83 ) , {c} chr( $89 ) , {d} chr( $99 ) ,
{e} chr( $91 ) , {f} chr( $8b ) , {g} chr( $9b ) , {h} chr( $93 ) , {i} chr( $8a ) ,
{j} chr( $9a ) , {k} chr( $85 ) , {l} chr( $87 ) , {m} chr( $8d ) , {n} chr( $9d ) ,
{o} chr( $95 ) , {p} chr( $8f ) , {q} chr( $9f ) , {r} chr( $97 ) , {s} chr( $8e ) ,
{t} chr( $9e ) , {u} chr( $a5 ) , {v} chr( $a7 ) , {w} chr( $ba ) , {x} chr( $ad ) ,
2011-11-10 18:23:42 +00:00
{y} chr( $bd ) , {z} chr( $b5 ) , '' , '' , '' , '' , '' , '' ) ;
2011-09-15 12:19:24 +00:00
d3: dictionary = ( {a + grave} chr( $ab ) , {a + acute} chr( $b7 ) ,
2011-11-10 18:23:42 +00:00
{a + circumflex} chr( $a1 ) , {a + tilde} chr( $9c ) , {a + diaeresis TODO} chr( $80 ) ,
{a + ring above TODO} chr( $80 ) , {ae TODO} chr( $80 ) , {c + cedilla} chr( $af ) ,
2011-09-15 12:19:24 +00:00
{e + grave} chr( $ae ) , {e + acute} chr( $bf ) , {e + circumflex} chr( $a3 ) ,
2011-11-10 18:23:42 +00:00
{e + diaeresis TODO} chr( $80 ) , {i + grave} chr( $a9 ) , {i + acute} chr( $8c ) ,
{i + circumflex TODO} chr( $80 ) , {i + diaeresis} chr( $bb ) , {eth TODO} chr( $80 ) ,
{n + tilde TODO} chr( $80 ) , {o + grave} chr( $ba ) , {o + acute} chr( $ac ) ,
{o + circumflex} chr( $b9 ) , {o + tilde} chr( $aa ) , {o + diaeresis TODO} chr( $80 ) ,
{division sign TODO} chr( $80 ) , {o + stroke TODO} chr( $80 ) , {u + grave} chr( $b1 ) ,
{u + acute} chr( $be ) , {u + circumflex TODO} chr( $80 ) , {u + diaeresis} chr( $b3 ) ,
2011-11-11 01:53:39 +00:00
{y + acute TODO} chr( $80 ) , {thorn TODO} chr( $80 ) , {y + diaeresis TODO} chr( $80 ) ) ; }
2011-09-15 13:43:59 +00:00
2011-11-11 01:53:39 +00:00
{ function ConvertUTF8TextToBraille( Line: string ) : string ;
{ var
2011-10-01 19:25:25 +00:00
lCharSize, count, n, next_n, len: integer ;
Braille_string: string ;
Pline: Pchar ;
num, caps: boolean ;
2011-09-15 12:19:24 +00:00
begin
Braille_string : = '' ;
num : = False ;
2011-10-01 19:25:25 +00:00
caps : = False ;
count : = 1 ;
2011-09-15 12:19:24 +00:00
if Line = '' then Result : = '' ;
2011-10-01 19:25:25 +00:00
len : = length( Line) ;
2011-11-11 01:53:39 +00:00
Pline : = PChar( Line) ; }
2011-09-15 12:19:24 +00:00
2011-10-01 19:25:25 +00:00
while count < = len do
2011-09-15 12:19:24 +00:00
begin
2011-10-01 19:25:25 +00:00
lCharSize : = LCLProc. UTF8CharacterLength( PLine) ;
if ( lCharSize = 1 ) then
2011-09-15 12:19:24 +00:00
begin
2011-10-01 19:25:25 +00:00
n : = Ord( Line[ count] ) ;
if ( n = 9 ) then Braille_string : = Braille_string + #9
else
if ( n = 1 0 ) then Braille_string : = Braille_string + #10
2011-11-10 18:23:42 +00:00
else
if ( n = 3 2 ) then Braille_string : = Braille_string + #32
2011-10-01 19:25:25 +00:00
else
2011-09-15 12:19:24 +00:00
begin
2011-10-01 19:25:25 +00:00
if ( ( n > = 9 7 ) and ( n < = 1 2 2 ) ) then {a lower case letter}
Braille_string : = Braille_string + chr( $e2 ) + chr( $a0 ) + d2[ n - 9 6 ]
2011-09-15 12:19:24 +00:00
2011-10-01 19:25:25 +00:00
else
begin
2011-09-15 12:19:24 +00:00
2011-10-01 19:25:25 +00:00
if ( ( n > = 6 5 ) and ( n < = 9 0 ) ) then {an upper case letter}
2011-09-15 12:19:24 +00:00
begin
2011-10-01 19:25:25 +00:00
if not caps then
begin
Braille_string : = Braille_string + caps_signal;
if ( count + 2 < length( Line) ) then
begin
next_n : = Ord( Line[ count + 1 ] ) ;
if ( ( next_n > = 6 5 ) and ( next_n < = 9 0 ) ) or ( ( next_n = 1 9 5 ) and ( ( Ord( Line[ count + 2 ] ) > = 1 2 8 ) and ( Ord( Line[ count + 2 ] ) < = 1 5 9 ) ) ) then {if the next char is also upper case, add another caps signal}
begin
Braille_string : = Braille_string + caps_signal;
caps : = True ;
end ;
end ;
end ;
2011-11-10 18:23:42 +00:00
Braille_string : = Braille_string + chr( $e2 ) + chr( $a0 ) + d2[ n - 6 4 ] ;
2011-10-01 19:25:25 +00:00
if ( count + 1 < = length( Line) ) then
begin
next_n : = Ord( Line[ count + 1 ] ) ;
if not( ( ( next_n > = 6 5 ) and ( next_n < = 9 0 ) ) or ( ( next_n = 1 9 5 ) and ( ( Ord( Line[ count + 2 ] ) > = 1 2 8 ) and ( Ord( Line[ count + 2 ] ) < = 1 5 9 ) ) ) ) then caps : = False ; {if the next char is not upper case, unflag <caps>}
end ;
end
else
2011-09-15 12:19:24 +00:00
begin
2011-10-01 19:25:25 +00:00
if ( n > = 4 8 ) and ( n < = 5 7 ) then {a number}
begin
if not num then Braille_string : = Braille_string + number_signal; {first algarism of a number, add a number signal}
num : = True ;
Braille_string : = Braille_string + chr( $e2 ) + chr( $a0 ) + d1[ n - 3 1 ] ;
if ( count + 1 < = length( Line) ) then
begin
next_n : = Ord( Line[ count + 1 ] ) ;
if not ( ( next_n > = 4 8 ) and ( next_n < = 5 7 ) or ( next_n = 4 4 ) or ( next_n = 4 6 ) ) then num : = False ; {the next char is not a number, nor ',', nor '.', then unflag <num>}
end ;
end
2011-09-15 12:19:24 +00:00
else
2011-10-01 19:25:25 +00:00
begin
2011-09-15 12:19:24 +00:00
2011-11-10 18:23:42 +00:00
if ( n > = 3 3 ) and ( n < = 6 4 ) then {a char from the first dictionary}
2011-10-01 19:25:25 +00:00
begin
2011-11-10 18:23:42 +00:00
Braille_string : = Braille_string + chr( $e2 ) + chr( $a0 ) + d1[ n - 3 2 ] ;
2011-10-01 19:25:25 +00:00
if ( count + 1 < = length( Line) ) then
begin
next_n : = Ord( Line[ count + 1 ] ) ;
if ( ( n = 4 4 ) or ( n = 4 6 ) ) and not ( ( next_n > = 4 8 ) and ( next_n < = 5 7 ) ) then num : = False ; {if the char is a ',' or a '.' but the next is not a number, unflag <num>}
end ;
end ;
end ;
end ;
end ;
end ;
end
2011-09-15 12:19:24 +00:00
2011-10-01 19:25:25 +00:00
else
2011-09-15 12:19:24 +00:00
begin
2011-10-01 19:25:25 +00:00
if ( lCharSize = 2 ) then
begin
n : = Ord( Line[ count] ) ;
if ( n = 1 9 5 ) then
begin
n : = Ord( Line[ count + 1 ] ) ;
if ( n > = 1 2 8 ) and ( n < = 1 5 9 ) then {upper case accented char}
begin
if not caps then
begin
Braille_string : = Braille_string + caps_signal;
if ( count + 2 < = length( Line) ) then
begin
next_n : = Ord( Line[ count + 2 ] ) ;
if ( ( next_n > = 6 5 ) and ( next_n < = 9 0 ) ) or ( ( next_n = 1 9 5 ) and ( ( Ord( Line[ count + 2 ] ) > = 1 2 8 ) and ( Ord( Line[ count + 2 ] ) < = 1 5 9 ) ) ) then {if the next char is also upper case, add another caps signal}
begin
Braille_string : = Braille_string + caps_signal;
caps : = True ;
end ;
end ;
end ;
Braille_string : = Braille_string + chr( $e2 ) + chr( $a0 ) + d3[ n - 1 2 7 ] ;
if ( count + 3 < = length( Line) ) then
begin
next_n : = Ord( Line[ count + 2 ] ) ;
if not( ( ( next_n > = 6 5 ) and ( next_n < = 9 0 ) ) or ( ( next_n = 1 9 5 ) and ( ( Ord( Line[ count + 3 ] ) > = 1 2 8 ) and ( Ord( Line[ count + 3 ] ) < = 1 5 9 ) ) ) ) then {if the next char is not upper case, unflag <caps>}
caps : = False ;
end ;
end
else
if ( n > = 1 6 0 ) and ( n < = 1 9 1 ) then Braille_string : = Braille_string + chr( $e2 ) + chr( $a0 ) + d3[ n - 1 5 9 ] ; {lower case accented letter}
end ;
end ;
end ;
count : = count + lCharSize;
Inc( Pline, lCharSize) ;
2011-09-15 12:19:24 +00:00
end ;
Result : = Braille_string;
2011-11-11 01:53:39 +00:00
end ; }
const
number_signal = chr( $e2 ) + chr( $a0 ) + chr( $bc ) ;
caps_signal = chr( $e2 ) + chr( $a0 ) + chr( $a8 ) ;
function ConvertUTF8CharToBraille( Char : string ; lCharSize: integer ; OrdChar: integer ) : string ;
const
aux = chr( $e2 ) + chr( $a0 ) ;
begin
{If the character can't be found in any of the cases, write a Braille space}
Result : = aux + chr( $80 ) ;
case lCharSize of
1 :
begin
case OrdChar of
9 : {\t}
Result : = #9 ;
1 0 : {\n}
Result : = #10 ;
3 2 : {<space>}
Result : = #32 ;
3 3 , 4 3 : {!, +}
Result : = aux + chr( $96 ) ;
3 4 : {"}
Result : = aux + chr( $a6 ) ;
3 6 : {*$*}
Result : = aux + chr( $b0 ) ;
3 7 : {%}
Result : = aux + chr( $b8 ) + chr( $e2 ) + chr( $a0 ) + chr( $b4 ) ;
3 8 : {&}
Result : = aux + chr( $af ) ;
3 9 , 4 6 : {', .}
Result : = aux + chr( $84 ) ;
4 0 : {(}
Result : = aux + chr( $a3 ) + chr( $e2 ) + chr( $a0 ) + chr( $84 ) ;
4 1 : {)}
Result : = aux + chr( $a0 ) + chr( $e2 ) + chr( $a0 ) + chr( $9c ) ;
4 2 : {*}
Result : = aux + chr( $94 ) ;
4 4 : {,}
Result : = aux + chr( $82 ) ;
4 5 : {-}
Result : = aux + chr( $a4 ) ;
4 7 : {/}
Result : = aux + chr( $90 ) + chr( $e2 ) + chr( $a0 ) + chr( $b2 ) ;
4 8 , 7 4 , 1 0 6 : {0, J, j}
Result : = aux + chr( $9a ) ;
4 9 , 6 5 , 9 7 : {1, A, a}
Result : = aux + chr( $81 ) ;
5 0 , 6 6 , 9 8 : {2, B, b}
Result : = aux + chr( $83 ) ;
5 1 , 6 7 , 9 9 : {3, C, c}
Result : = aux + chr( $89 ) ;
5 2 , 6 8 , 1 0 0 : {4, D, d}
Result : = aux + chr( $99 ) ;
5 3 , 6 9 , 1 0 1 : {5, E, e}
Result : = aux + chr( $91 ) ;
5 4 , 7 0 , 1 0 2 : {6, F, f}
Result : = aux + chr( $8b ) ;
5 5 , 7 1 , 1 0 3 : {7, G, g}
Result : = aux + chr( $9b ) ;
5 6 , 7 2 , 1 0 4 : {8, H, h}
Result : = aux + chr( $93 ) ;
5 7 , 7 3 , 1 0 5 : {9, I, i}
Result : = aux + chr( $8a ) ;
5 8 : {:}
Result : = aux + chr( $92 ) ;
5 9 : {;}
Result : = aux + chr( $86 ) ;
6 0 : {<}
Result : = aux + chr( $aa ) ;
6 1 : {=}
Result : = aux + chr( $b6 ) ;
6 3 : {?}
Result : = aux + chr( $a2 ) ;
7 5 , 1 0 7 : {K, k}
Result : = aux + chr( $85 ) ;
7 6 , 1 0 8 : {L, l}
Result : = aux + chr( $87 ) ;
7 7 , 1 0 9 : {M, m}
Result : = aux + chr( $8d ) ;
7 8 , 1 1 0 : {N, n}
Result : = aux + chr( $9d ) ;
7 9 , 1 1 1 , 6 2 : {O, o, >}
Result : = aux + chr( $95 ) ;
8 0 , 1 1 2 : {P, p}
Result : = aux + chr( $8f ) ;
8 1 , 1 1 3 : {Q, q}
Result : = aux + chr( $9f ) ;
8 2 , 1 1 4 : {R, r}
Result : = aux + chr( $97 ) ;
8 3 , 1 1 5 : {S, s}
Result : = aux + chr( $8e ) ;
8 4 , 1 1 6 : {T, t}
Result : = aux + chr( $9e ) ;
8 5 , 1 1 7 : {U, u}
Result : = aux + chr( $a5 ) ;
8 6 , 1 1 8 : {V, v}
Result : = aux + chr( $a7 ) ;
8 7 , 1 1 9 : {W, w}
Result : = aux + chr( $ba ) ;
8 8 , 1 2 0 : {X, x}
Result : = aux + chr( $ad ) ;
8 9 , 1 2 1 : {Y, y}
Result : = aux + chr( $bd ) ;
9 0 , 1 2 2 : {Z, z}
Result : = aux + chr( $b5 ) ;
end ;
end ;
2 :
begin
case OrdChar of
1 9 5 : {accented letter}
begin
OrdChar : = Ord( Char [ 2 ] ) ;
case OrdChar of
1 2 8 , 1 6 0 : {A + grave, a + grave}
Result : = aux + chr( $ab ) ;
1 2 9 , 1 6 1 : {A + acute, a + acute}
Result : = aux + chr( $b7 ) ;
1 3 0 , 1 6 2 : {A + circumflex, a + circumflex}
Result : = aux + chr( $a1 ) ;
1 3 1 , 1 6 3 : {A + tilde, a + tilde}
Result : = aux + chr( $9c ) ;
1 3 5 , 1 6 7 : {C + cedilla, c + cedilla}
Result : = aux + chr( $af ) ;
1 3 6 , 1 6 8 : {E + grave, e + grave}
Result : = aux + chr( $ae ) ;
1 3 7 , 1 6 9 : {E + acute, e + acute}
Result : = aux + chr( $bf ) ;
1 3 8 , 1 7 0 : {E + circumflex, e + circumflex}
Result : = aux + chr( $a3 ) ;
1 4 0 , 1 7 2 : {I + grave, i + grave}
Result : = aux + chr( $a9 ) ;
1 4 1 , 1 7 3 : {I + acute, i + acute}
Result : = aux + chr( $8c ) ;
1 4 3 , 1 7 5 : {I + diaresis, i + diaresis}
Result : = aux + chr( $bb ) ;
1 4 6 , 1 7 8 : {O + grave, o + grave}
Result : = aux + chr( $ba ) ;
1 4 7 , 1 7 9 : {O + acute, o + acute}
Result : = aux + chr( $ac ) ;
1 4 8 , 1 8 0 : {O + circumflex, o + circumflex}
Result : = aux + chr( $b9 ) ;
1 4 9 , 1 8 1 : {O + tilde, o + tilde}
Result : = aux + chr( $aa ) ;
1 5 3 , 1 8 5 : {U + grave, u + grave}
Result : = aux + chr( $b1 ) ;
1 5 4 , 1 8 6 : {U + acute, u + acute}
Result : = aux + chr( $be ) ;
1 5 6 , 1 8 8 : {U + diaeresis, u + diaeresis}
Result : = aux + chr( $b3 ) ;
end ;
end ;
end ;
end ;
end ;
end ;
function ConvertUTF8TextToBraille( Text : string ) : string ;
var
lCharSize, TextSize, i, OrdChar, nextOrdChar: integer ;
Braille_string: string ;
PText: Pchar ;
IsNum: boolean ;
begin
Braille_string : = '' ;
IsNum : = False ;
if Text = '' then Result : = '' ;
TextSize : = Length( Text ) ;
PText : = PChar( Text ) ;
i : = 1 ;
while i < = TextSize do
begin
lCharSize : = LCLProc. UTF8CharacterLength( PText) ;
OrdChar : = Ord( Text [ i] ) ;
case lCharSize of
1 :
begin
case OrdChar of
4 8 .. 5 7 : {a number}
begin
if not IsNum then
begin
Braille_string : = Braille_string + number_signal; {first algarism of a number, add a number signal}
IsNum : = True
end ;
if ( i + 1 < = TextSize) then
begin
nextOrdChar : = Ord( Text [ i + 1 ] ) ;
if not ( ( nextOrdChar > = 4 8 ) and ( nextOrdChar < = 5 7 ) or ( nextOrdChar = 4 4 ) or ( nextOrdChar = 4 6 ) ) then IsNum : = False ; {the next char is not a number, nor ',', nor '.', then unflag <IsNum>}
end ;
end ;
6 5 .. 9 0 : {Upper case letter, add a caps_signal}
Braille_string : = Braille_string + caps_signal;
end ;
Braille_string : = Braille_string + ConvertUTF8CharToBraille( Text [ i] , 1 , OrdChar) ;
i : = i + 1 ;
end ;
2 :
begin
nextOrdChar : = Ord( Text [ i+ 1 ] ) ;
case nextOrdChar of
{Accented upper case letter, add a caps_signal}
1 2 8 .. 1 5 9 :
Braille_string : = Braille_string + caps_signal;
end ;
Braille_string : = Braille_string + ConvertUTF8CharToBraille( copy( Text , i, 2 ) , 2 , OrdChar) ;
i : = i + 2 ;
end ;
end ;
Inc( PText, lCharSize) ;
end ;
Result : = Braille_string;
2011-09-15 12:19:24 +00:00
end ;
function ConvertUTF8HtmlTextToBraille( AInput: string ) : string ;
2011-09-15 13:10:18 +00:00
var
2011-10-19 18:00:31 +00:00
i, lCharSize: integer ;
2011-10-01 19:25:25 +00:00
output, aux_string, end_string: string ;
2011-09-15 13:10:18 +00:00
is_text: boolean ;
2011-10-01 19:25:25 +00:00
Pline : PChar ;
2011-09-15 12:19:24 +00:00
begin
2011-09-15 13:10:18 +00:00
i : = 1 ;
output : = '' ;
aux_string : = '' ;
2011-10-01 19:25:25 +00:00
is_text : = False ;
Pline : = PChar( AInput) ;
2011-09-15 13:10:18 +00:00
2011-10-01 19:25:25 +00:00
while i < = length( AInput) do
2011-09-15 13:10:18 +00:00
begin
2011-10-01 19:25:25 +00:00
end_string : = '' ;
while is_text and ( i < = length( AInput) ) do
2011-09-15 13:10:18 +00:00
begin
2011-10-19 18:00:31 +00:00
if ( AInput[ i] = '<' ) then { an instruction comes next }
2011-09-15 13:10:18 +00:00
begin
is_text : = False ;
2011-10-01 19:25:25 +00:00
i : = i + 1 ;
Inc( Pline, 1 ) ;
end_string : = '<' ;
2011-10-19 18:00:31 +00:00
if ( copy( AInput, i, 6 ) = 'script' ) then { if it' s a script, go through it and
keep reading the text }
begin
i : = i + 6 ;
Inc( Pline, 6 ) ;
end_string : = end_string + 'script' ;
while ( copy( AInput, i, 9 ) < > '</script>' ) do
begin
end_string : = end_string + AInput[ i] ;
i : = i + 1 ;
Inc( Pline, 1 ) ;
end ;
is_text : = True ;
end ;
2011-10-01 19:25:25 +00:00
break;
2011-09-15 13:10:18 +00:00
end ;
2011-10-01 19:25:25 +00:00
2011-10-19 18:00:31 +00:00
{ Read the next UTF8 character add it to aux_string }
2011-10-01 19:25:25 +00:00
lCharSize : = LCLProc. UTF8CharacterLength( Pline) ;
2011-10-19 18:00:31 +00:00
aux_string : = aux_string + copy( AInput, i, lCharSize) ;
2011-10-01 19:25:25 +00:00
i : = i + lCharSize;
Inc( Pline, lCharSize) ;
2011-09-15 13:10:18 +00:00
end ;
2011-10-19 18:00:31 +00:00
{ Translate aux_string to Braille and add it to output }
2011-10-01 19:25:25 +00:00
output : = output + ConvertUTF8TextToBraille( aux_string) + end_string;
aux_string : = '' ;
2011-09-15 13:10:18 +00:00
2011-10-01 19:25:25 +00:00
while ( not is_text) and ( i < = length( AInput) ) do
2011-09-15 13:10:18 +00:00
begin
2011-10-19 18:00:31 +00:00
if ( AInput[ i] = '>' ) then { End of instruction }
2011-09-15 13:10:18 +00:00
begin
is_text : = True ;
i : = i + 1 ;
2011-10-01 19:25:25 +00:00
Inc( Pline, 1 ) ;
2011-09-15 13:10:18 +00:00
output : = output + '>' ;
break
end ;
2011-10-19 18:00:31 +00:00
{ Add the next UTF8 character straight to output, without translating it }
2011-10-01 19:25:25 +00:00
lCharSize : = LCLProc. UTF8CharacterLength( Pline) ;
2011-10-19 18:00:31 +00:00
output : = output + copy( AInput, i, lCharSize) ;
2011-10-01 19:25:25 +00:00
i : = i + lCharSize;
Inc( Pline, lCharSize) ;
2011-09-15 13:10:18 +00:00
end ;
end ;
ConvertUTF8HtmlTextToBraille : = output;
2011-09-15 12:19:24 +00:00
end ;
{ TBrailleBrowserModule }
constructor TBrailleBrowserModule. Create;
begin
inherited Create;
ShortDescription : = 'Braille Module' ;
end ;
function TBrailleBrowserModule. HandleOnPageLoad( AInput: string ; out
AOutput: string ) : Boolean ;
begin
AOutput : = ConvertUTF8HtmlTextToBraille( AInput) ;
2011-11-10 18:23:42 +00:00
Result : = True ;
2011-09-15 12:19:24 +00:00
end ;
initialization
RegisterBrowserModule( TBrailleBrowserModule. Create( ) ) ;
end .