| 1 | # ################################################################### Otakar Smrz, 2003/01/23 | ||||||||||
| 2 | # | ||||||||||
| 3 | # Encoding of Arabic: ArabTeX Notation by Klaus Lagally ##################################### | ||||||||||
| 4 | |||||||||||
| 5 | package Encode::Arabic::ArabTeX::ZDMG::RE; | ||||||||||
| 6 | |||||||||||
| 7 | 2 | our $VERSION = '14.1'; | |||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 2 | ▶ | sub import { # perform import as if Encode were used one level before this module | ||||||||
|
Subroutine
import: called CC=2 SCAR=6.9
| |||||||||||
| 15 | 2 | require Encode; | |||||||||
| 16 | 2 | ▶ | push @Encode::ISA, 'Exporter' unless Encode->can('export_to_level'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 2 | Encode->export_to_level(1, @_); | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | 2 | ▶ | use Encode::Encoding; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 2 | ▶ | use base 'Encode::Encoding'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | 2 | __PACKAGE__->Define('ZDMG-RE', 'ArabTeX-ZDMG-RE'); | |||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | 2 | our (%encode_used, %decode_used, @shams, @qamar); | |||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | sub encode ($$;$$) { | ||||||||
|
Subroutine
encode: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 31 | 0 | my (undef, $text, $check, $mode) = @_; | |||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | $_[1] = '' if $check; # this is what in-place edit needs | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 0 | ▶ | $text = Encode::encode "utf8", $text if Encode::is_utf8($text); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | |||||||||||
| 37 | 0 | return $text; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub decode ($$;$) { | ||||||||
|
Subroutine
decode: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 42 | 0 | my (undef, $text, $check) = @_; | |||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | $_[1] = '' if $check; # this is what in-place edit needs | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | |||||||||||
| 46 | 0 | ▶ | $text = Encode::decode "utf8", $text unless Encode::is_utf8($text); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | |||||||||||
| 48 | 0 | for ($text) { | |||||||||
| 49 | |||||||||||
| 50 | 0 | s/NY/n/g; | |||||||||
| 51 | 0 | s/UA/u\x{0304}/g; | |||||||||
| 52 | 0 | s/WA/w/g; | |||||||||
| 53 | 0 | s/_a/a\x{0304}/g; | |||||||||
| 54 | |||||||||||
| 55 | 0 | s/N/n/g; | |||||||||
| 56 | 0 | s/Y/a\x{0304}/g; | |||||||||
| 57 | 0 | s/T/t/g; | |||||||||
| 58 | |||||||||||
| 59 | #s/y/j/g; | ||||||||||
| 60 | |||||||||||
| 61 | 0 | s/\\cap\s+([\._\^]?)([a-zAIU])/$1\*$2/g; | |||||||||
| 62 | 0 | s/\\cap\s+(['`])([a-zAIUEO])/\*$1\*$2/g; | |||||||||
| 63 | |||||||||||
| 64 | 0 | s/\.(\*?[hsdtz])/$1\x{0323}/g; | |||||||||
| 65 | 0 | s/\.(\*?g)/$1\x{0307}/g; | |||||||||
| 66 | |||||||||||
| 67 | 0 | s/_(\*?[td])/$1\x{0331}/g; | |||||||||
| 68 | 0 | s/_(\*?)h/$1\x{032E}/g; | |||||||||
| 69 | |||||||||||
| 70 | #s/_(\*?)h/$1ch/g; | ||||||||||
| 71 | |||||||||||
| 72 | 0 | s/\^(\*?[gs])/$1\x{030C}/g; | |||||||||
| 73 | |||||||||||
| 74 | #s/\^(\*?s)/\\v{$1}/g; | ||||||||||
| 75 | #s/\^(\*?)g/$1d\\v{z}/g; | ||||||||||
| 76 | |||||||||||
| 77 | 0 | s/(?<!\*)([AUEO])/\l$1\x{0304}/g; | |||||||||
| 78 | 0 | s/(?<!\*)I/\x{0131}\x{0304}/g; | |||||||||
| 79 | 0 | s/\*([AIUEO])/$1\x{0304}/g; | |||||||||
| 80 | |||||||||||
| 81 | 0 | s/\*?'/\x{02BE}/g; | |||||||||
| 82 | 0 | s/\*?`/\x{02BF}/g; | |||||||||
| 83 | |||||||||||
| 84 | 0 | s/\*([a-z])/\u$1/g; | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | 0 | return $text; | |||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | |||||||||||
| 91 | 2 | 1; | |||||||||
| 92 | |||||||||||
| 93 | __END__ | ||||||||||