Encode-Arabic-14.1 000755 001750 001750 0 12410623243 13735 5 ustar 00otakar otakar 000000 000000 Encode-Arabic-14.1/MANIFEST 000444 001750 001750 1512 12410623243 15222 0 ustar 00otakar otakar 000000 000000 bin/decode.pl
bin/encode.pl
Build.PL
cgi/encode/index.fcgi
cgi/encode/index.html
css/encode.css
css/encode.js
lib/Encode/Arabic.pm
lib/Encode/Arabic/ArabTeX.pm
lib/Encode/Arabic/ArabTeX/RE.pm
lib/Encode/Arabic/ArabTeX/Verbatim.pm
lib/Encode/Arabic/ArabTeX/ZDMG.pm
lib/Encode/Arabic/ArabTeX/ZDMG/RE.pm
lib/Encode/Arabic/Buckwalter.pm
lib/Encode/Arabic/CGI.pm
lib/Encode/Arabic/Exec.pm
lib/Encode/Arabic/Habash.pm
lib/Encode/Arabic/Parkinson.pm
lib/Encode/Mapper.pm
LICENSE
MANIFEST
README
t/Encode-Arabic-ArabTeX-RE.t
t/Encode-Arabic-ArabTeX-Verbatim.t
t/Encode-Arabic-ArabTeX-ZDMG-RE.t
t/Encode-Arabic-ArabTeX-ZDMG.t
t/Encode-Arabic-ArabTeX.t
t/Encode-Arabic-Buckwalter.t
t/Encode-Arabic-Habash.t
t/Encode-Arabic-Parkinson.t
t/Encode-Arabic.t
t/Encode-Mapper-1.t
t/Encode-Mapper-2.t
t/Encode-Mapper-3.t
t/Encode-Mapper-4.t
META.yml
META.json
Encode-Arabic-14.1/LICENSE 000444 001750 001750 104513 12410623243 15143 0 ustar 00otakar otakar 000000 000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
Encode-Arabic-14.1/Build.PL 000444 001750 001750 1303 12410623243 15363 0 ustar 00otakar otakar 000000 000000 use Module::Build;
use strict;
use warnings;
my $build = Module::Build->new(
module_name => 'Encode::Arabic',
license => 'perl',
dist_author => 'Otakar Smrz ',
dist_version_from => 'lib/Encode/Arabic.pm',
requires => {
'perl' => 5.008,
},
configure_requires => {
'Module::Build' => 0.38,
},
build_requires => {
'Test::More' => 0,
},
add_to_cleanup => [ 'Encode-Arabic-*' ],
);
$build->create_build_script();
Encode-Arabic-14.1/META.yml 000444 001750 001750 2750 12410623243 15347 0 ustar 00otakar otakar 000000 000000 ---
abstract: 'Encodings of Arabic'
author:
- 'Otakar Smrz '
build_requires:
Test::More: 0
configure_requires:
Module::Build: 0.38
dynamic_config: 1
generated_by: 'Module::Build version 0.4007, CPAN::Meta::Converter version 2.110440'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: Encode-Arabic
provides:
Encode::Arabic:
file: lib/Encode/Arabic.pm
version: 14.1
Encode::Arabic::ArabTeX:
file: lib/Encode/Arabic/ArabTeX.pm
version: 14.1
Encode::Arabic::ArabTeX::RE:
file: lib/Encode/Arabic/ArabTeX/RE.pm
version: 14.1
Encode::Arabic::ArabTeX::Verbatim:
file: lib/Encode/Arabic/ArabTeX/Verbatim.pm
version: 14.1
Encode::Arabic::ArabTeX::ZDMG:
file: lib/Encode/Arabic/ArabTeX/ZDMG.pm
version: 14.1
Encode::Arabic::ArabTeX::ZDMG::RE:
file: lib/Encode/Arabic/ArabTeX/ZDMG/RE.pm
version: 14.1
Encode::Arabic::Buckwalter:
file: lib/Encode/Arabic/Buckwalter.pm
version: 14.1
Encode::Arabic::CGI:
file: lib/Encode/Arabic/CGI.pm
version: 14.1
Encode::Arabic::Exec:
file: lib/Encode/Arabic/Exec.pm
version: 14.1
Encode::Arabic::Habash:
file: lib/Encode/Arabic/Habash.pm
version: 14.1
Encode::Arabic::Parkinson:
file: lib/Encode/Arabic/Parkinson.pm
version: 14.1
Encode::Mapper:
file: lib/Encode/Mapper.pm
version: 14.1
requires:
perl: 5.008
resources:
license: http://dev.perl.org/licenses/
version: 14.1
Encode-Arabic-14.1/README 000444 001750 001750 1631 12410623243 14753 0 ustar 00otakar otakar 000000 000000 Encode Arabic - Encodings of Arabic
Encode Arabic is a wrapper for modules implementing the various encoding
systems used for the Arabic language and covering even some non-Arabic
extensions to the Arabic script. The modules fit in the philosophy of
Encode::Encoding and can be used directly with the Encode module.
INSTALLATION
To install this module, run the following from the command line:
perl Build.PL
Build
Build test
Build install
or use the Perl Package Manager instead and run
ppm
to enter the interactive interface for module management.
DOCUMENTATION
Visit the site http://search.cpan.org/dist/Encode-Arabic/ or run
perldoc [file|module]
in order to get more information on this and related software.
COPYRIGHT AND LICENCE
Copyright (C) 2003-2014 Otakar Smrz
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
Encode-Arabic-14.1/META.json 000444 001750 001750 4513 12410623243 15516 0 ustar 00otakar otakar 000000 000000 {
"abstract" : "Encodings of Arabic",
"author" : [
"Otakar Smrz "
],
"dynamic_config" : 1,
"generated_by" : "Module::Build version 0.4007, CPAN::Meta::Converter version 2.110440",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "Encode-Arabic",
"prereqs" : {
"build" : {
"requires" : {
"Test::More" : 0
}
},
"configure" : {
"requires" : {
"Module::Build" : "0.38"
}
},
"runtime" : {
"requires" : {
"perl" : "5.008"
}
}
},
"provides" : {
"Encode::Arabic" : {
"file" : "lib/Encode/Arabic.pm",
"version" : "14.1"
},
"Encode::Arabic::ArabTeX" : {
"file" : "lib/Encode/Arabic/ArabTeX.pm",
"version" : "14.1"
},
"Encode::Arabic::ArabTeX::RE" : {
"file" : "lib/Encode/Arabic/ArabTeX/RE.pm",
"version" : "14.1"
},
"Encode::Arabic::ArabTeX::Verbatim" : {
"file" : "lib/Encode/Arabic/ArabTeX/Verbatim.pm",
"version" : "14.1"
},
"Encode::Arabic::ArabTeX::ZDMG" : {
"file" : "lib/Encode/Arabic/ArabTeX/ZDMG.pm",
"version" : "14.1"
},
"Encode::Arabic::ArabTeX::ZDMG::RE" : {
"file" : "lib/Encode/Arabic/ArabTeX/ZDMG/RE.pm",
"version" : "14.1"
},
"Encode::Arabic::Buckwalter" : {
"file" : "lib/Encode/Arabic/Buckwalter.pm",
"version" : "14.1"
},
"Encode::Arabic::CGI" : {
"file" : "lib/Encode/Arabic/CGI.pm",
"version" : "14.1"
},
"Encode::Arabic::Exec" : {
"file" : "lib/Encode/Arabic/Exec.pm",
"version" : "14.1"
},
"Encode::Arabic::Habash" : {
"file" : "lib/Encode/Arabic/Habash.pm",
"version" : "14.1"
},
"Encode::Arabic::Parkinson" : {
"file" : "lib/Encode/Arabic/Parkinson.pm",
"version" : "14.1"
},
"Encode::Mapper" : {
"file" : "lib/Encode/Mapper.pm",
"version" : "14.1"
}
},
"release_status" : "stable",
"resources" : {
"license" : [
"http://dev.perl.org/licenses/"
]
},
"version" : "14.1"
}
Encode-Arabic-14.1/t 000755 001750 001750 0 12410623243 14200 5 ustar 00otakar otakar 000000 000000 Encode-Arabic-14.1/t/Encode-Arabic.t 000444 001750 001750 2367 12410623243 17106 0 ustar 00otakar otakar 000000 000000 #########################
use Test::More tests => 16;
BEGIN {
use_ok 'Encode::Arabic';
}
BEGIN {
use_ok 'Encode::Arabic', 'from_to';
}
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
ok defined &encode, "import Encode's encode() function";
ok defined &decode, "import Encode's decode() function";
ok defined &encode_utf8, "import Encode's encode_utf8() function";
ok defined &decode_utf8, "import Encode's decode_utf8() function";
ok defined &encodings, "import Encode's encodings() function";
ok defined &find_encoding, "import Encode's find_encoding() function";
ok defined &from_to, "import Encode's from_to() function";
ok ref (find_encoding 'arabtex'), 'ArabTeX known with its alias';
ok ref (find_encoding 'arabtex-re'), 'ArabTeX-RE known, too';
ok ref (find_encoding 'arabtex-verbatim'), 'ArabTeX-Verbatim known with its alias';
ok ref (find_encoding 'arabtex-zdmg'), 'ArabTeX-ZDMG known with its alias';
ok ref (find_encoding 'arabtex-zdmg-re'), 'ArabTeX-ZDMG-RE known, too';
ok ref (find_encoding 'buckwalter'), 'Buckwalter known with its alias';
ok ref (find_encoding 'parkinson'), 'Parkinson known with its alias';
Encode-Arabic-14.1/t/Encode-Arabic-ArabTeX-RE.t 000444 001750 001750 436 12410623243 20651 0 ustar 00otakar otakar 000000 000000 #########################
use Test::More tests => 1;
BEGIN {
use_ok 'Encode::Arabic::ArabTeX::RE';
}
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
Encode-Arabic-14.1/t/Encode-Mapper-4.t 000444 001750 001750 2325 12410623243 17304 0 ustar 00otakar otakar 000000 000000 #########################
use Test::More tests => 1;
require_ok 'Encode::Mapper';
__END__
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
use Data::Dump 'dump'; # pretty data printing is below
$Encode::Mapper::options{'ByForce'} = { qw ':others - silent errors' };
package ByMethod; # import called at compile time
# no warnings, 'silent' is true
Encode::Mapper->options('complement' => [ 'X', 'Y' ], 'others' => 'X');
use Encode::Mapper 'silent' => 299_792_458;
package main; # import called at compile time
# 'non-existent' may exist once
print dump %Encode::Mapper::options;
use Encode::Mapper ':others', ':silent', 'non-existent', 'one';
# (
# "ByMethod",
# { complement => ["X", "Y"], others => "X", silent => 299_792_458 },
# "ByForce",
# { ":others" => "-", silent => "errors" },
# "main",
# { "non-existent" => "one", others => sub { "???" }, silent => 1 },
# )
Encode-Arabic-14.1/t/Encode-Arabic-ArabTeX-ZDMG.t 000444 001750 001750 3371 12410623243 21125 0 ustar 00otakar otakar 000000 000000 #########################
use Test::More tests => 10;
BEGIN {
use_ok 'Encode::Arabic::ArabTeX::ZDMG', ':xml';
}
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
can_ok 'Encode::Arabic::ArabTeX::ZDMG', qw 'encode decode encoder decoder';
ok defined &encode, "import Encode's encode() function";
ok defined &decode, "import Encode's decode() function";
$Encode::Mapper::options{'Encode::Arabic::ArabTeX::ZDMG'}{'join'} = undef;
my $encoder = Encode::Arabic::ArabTeX::ZDMG->encoder();
my $decoder = Encode::Arabic::ArabTeX::ZDMG->decoder();
ok defined $Encode::Arabic::ArabTeX::ZDMG::encoder, 'encoder defined';
ok defined $Encode::Arabic::ArabTeX::ZDMG::decoder, 'decoder defined';
my $utf = decode "utf8", "\x49\x71\x72\x61\xCA\xBE\x20" . "\x68\xC4\x81\xE1\xB8\x8F\xC4\x81\x20" .
"\xCA\xBC\x6E\x2D\x6E\x61\xE1\xB9\xA3\xE1\xB9\xA3\x61\x20" .
"\x62\x69\x2D\xCA\xBC\x6E\x74\x69\x62\xC4\x81\x68\x69\x6E\x2E\x20" .
"\x4B\x61\x79\x66\x61\x20" . "\xCA\xBC\x6C\x2D\xE1\xB8\xA5\xC4\x81\x6C\x75\x3F";
my $tex = "\\cap iqra' h_a_dA an-na.s.sa bi-intibAhiN. \\cap kayfa al-.hAlu?";
my $encode = encode "arabtex-zdmg", $utf;
my $decode = decode "arabtex-zdmg", $tex;
TODO: {
local $TODO = 'Non-simple mapping';
is $encode, $tex, '$encode is $tex';
# is $decode, $utf, '$decode is $utf';
is $encode, (encode "arabtex-zdmg", $decode), 'encode(..., $decode) is fine';
# is $decode, (decode "arabtex-zdmg", $encode), 'decode(..., $encode) is fine';
}
ok ! Encode::is_utf8($encode), "from Perl's internal utf8: " . $encode;
ok Encode::is_utf8($decode), "into Perl's internal utf8: " . encode 'utf8', $decode;
Encode-Arabic-14.1/t/Encode-Arabic-ArabTeX-Verbatim.t 000444 001750 001750 3627 12410623243 22141 0 ustar 00otakar otakar 000000 000000 #########################
use Test::More tests => 10;
BEGIN {
use_ok 'Encode::Arabic::ArabTeX::Verbatim', ':xml';
}
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
can_ok 'Encode::Arabic::ArabTeX::Verbatim', qw 'encode decode encoder decoder';
ok defined &encode, "import Encode's encode() function";
ok defined &decode, "import Encode's decode() function";
$Encode::Mapper::options{'Encode::Arabic::ArabTeX::Verbatim'}{'join'} = undef;
my $encoder = Encode::Arabic::ArabTeX::Verbatim->encoder();
my $decoder = Encode::Arabic::ArabTeX::Verbatim->decoder();
ok defined $Encode::Arabic::ArabTeX::Verbatim::encoder, 'encoder defined';
ok defined $Encode::Arabic::ArabTeX::Verbatim::decoder, 'decoder defined';
my $utf = "\x{0627}\x{0650}\x{0642}\x{0652}\x{0631}\x{064E}\x{0623}\x{0652} " .
"\x{0647}\x{0670}\x{0630}\x{064E}\x{0627} " .
"\x{0671}\x{0644}\x{0646}\x{0651}\x{064E}\x{0635}\x{0651}\x{064E} " .
"\x{0628}\x{0650}\x{0671}\x{0646}\x{0652}\x{062A}\x{0650}\x{0628}\x{064E}\x{0627}\x{0647}\x{064D}. " .
"\x{0643}\x{064E}\x{064A}\x{0652}\x{0641}\x{064E} " .
"\x{0671}\x{0644}\x{0652}\x{062D}\x{064E}\x{0627}\x{0644}\x{064F}\x{061F}";
my $tex = "iqra'a h_a_dA al-n||a.s||a bi-intibAhiN. kayfa al-.hAlu?";
my $encode = encode "arabtex-verb", $utf;
my $decode = decode "arabtex-verb", $tex;
TODO: {
local $TODO = 'Non-simple mapping';
is $encode, $tex, '$encode is $tex';
# is $decode, $utf, '$decode is $utf';
is $encode, (encode "arabtex-verb", $decode), 'encode(..., $decode) is fine';
# is $decode, (decode "arabtex-verb", $encode), 'decode(..., $encode) is fine';
}
ok ! Encode::is_utf8($encode), "from Perl's internal utf8: " . $encode;
ok Encode::is_utf8($decode), "into Perl's internal utf8: " . encode 'utf8', $decode;
Encode-Arabic-14.1/t/Encode-Arabic-Buckwalter.t 000444 001750 001750 2676 12410623243 21212 0 ustar 00otakar otakar 000000 000000 #########################
use Test::More tests => 7;
BEGIN {
use_ok 'Encode::Arabic::Buckwalter', ':xml';
}
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
my $utf = "\x{0627}\x{0650}\x{0642}\x{0652}\x{0631}\x{064E}\x{0623}\x{0652} " .
"\x{0647}\x{0670}\x{0630}\x{064E}\x{0627} " .
"\x{0671}\x{0644}\x{0646}\x{0651}\x{064E}\x{0635}\x{0651}\x{064E} " .
"\x{0628}\x{0650}\x{0671}\x{0646}\x{0652}\x{062A}\x{0650}\x{0628}\x{064E}\x{0627}\x{0647}\x{064D}. " .
"\x{0643}\x{064E}\x{064A}\x{0652}\x{0641}\x{064E} " .
"\x{0671}\x{0644}\x{0652}\x{062D}\x{064E}\x{0627}\x{0644}\x{064F}\x{061F}";
my $tim = "AiqoraOo h`*aA {ln~aS~a bi{notibaAhK. kayofa {loHaAlu?";
my $encode = encode "buckwalter", $utf;
my $decode = decode "buckwalter", $tim;
is $encode, $tim, '$encode is $tim';
is $decode, $utf, '$decode is $utf';
is $encode, (encode "buckwalter", $decode), 'encode(..., $decode) is fine';
is $decode, (decode "buckwalter", $encode), 'decode(..., $encode) is fine';
$using_xml = eval q { use Encode::Arabic::Buckwalter ':xml'; decode 'buckwalter', 'OWI' };
$classical = eval q { use Encode::Arabic::Buckwalter; decode 'buckwalter', '>&<' };
is $classical, $using_xml, '$classical eq $using_xml';
is $classical, "\x{0623}\x{0624}\x{0625}", '$classical eq "\x{0623}\x{0624}\x{0625}"';
Encode-Arabic-14.1/t/Encode-Mapper-1.t 000444 001750 001750 5305 12410623243 17302 0 ustar 00otakar otakar 000000 000000 #########################
use Test::More tests => 9;
BEGIN {
use_ok 'Encode::Mapper';
}
require_ok 'Encode';
require_ok 'Data::Dumper';
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
can_ok 'Encode::Mapper', qw 'new compile process recover compute dumper',
qw 'encode decode', qw 'options import';
my $mapper = Encode::Mapper->new (
map {
(chr $_) x 2,
} 0x00..0xFF
);
my @tokens = (
"\x{060C}", ",", "\x{0637}", ".t",
"\x{061B}", ";", "\x{0638}", ".z",
"\x{061F}", "?", "\x{0639}", "`",
"\x{0621}", "'", "\x{063A}", ".g",
"\x{0622}", "'A", "\x{0640}", "--",
"\x{0623}", "'", "\x{0641}", "f",
"\x{0624}", "'", "\x{0642}", "q",
"\x{0625}", "'", "\x{0643}", "k",
"\x{0626}", "'", "\x{0644}", "l",
"\x{0627}", "A", "\x{0645}", "m",
"\x{0628}", "b", "\x{0646}", "n",
"\x{0629}", "T", "\x{0647}", "h",
"\x{062A}", "t", "\x{0648}", "w",
"\x{062B}", "_t", "\x{0649}", "Y",
"\x{062C}", "^g", "\x{064A}", "y",
"\x{062D}", ".h", "\x{064B}", "aN",
"\x{062E}", "_h", "\x{064C}", "uN",
"\x{062F}", "d", "\x{064D}", "iN",
"\x{0630}", "_d", "\x{064E}", "a",
"\x{0631}", "r", "\x{064F}", "u",
"\x{0632}", "z", "\x{0650}", "i",
"\x{0633}", "s", "\x{0651}", "\\shadda{}",
"\x{0634}", "^s", "\x{0652}", "\\sukuun{}",
"\x{0635}", ".s", "\x{0670}", "_a",
"\x{0636}", ".d", "\x{0671}", "A",
);
push @tokens, qw 'ě š č ř ž ý á í é = ů ú';
ok defined $mapper, "use compile() as the constructor";
ok $mapper->isa('Encode::Mapper'), "constructs the right class";
is Encode::decode_utf8(join "", map {
UNIVERSAL::isa($_, 'CODE') ? $_->() : $_
} $mapper->process(@tokens), $mapper->recover()),
join("", map { Encode::is_utf8($_) ? $_ : Encode::decode_utf8($_) } @tokens),
"identity mapping, bytes oriented";
is_deeply [ my @x = split //, "\x{c4}\x{80}"],
[ split //, Encode::encode("utf8", "\x{0100}") ],
'unicodeness test';
is_deeply [ map { ord } @x ], [ 0xC4, 0x80 ], 'byte comparison';
Encode-Arabic-14.1/t/Encode-Arabic-ArabTeX-ZDMG-RE.t 000444 001750 001750 444 12410623243 21407 0 ustar 00otakar otakar 000000 000000 #########################
use Test::More tests => 1;
BEGIN {
use_ok 'Encode::Arabic::ArabTeX::ZDMG::RE';
}
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
Encode-Arabic-14.1/t/Encode-Arabic-ArabTeX.t 000444 001750 001750 3472 12410623243 20370 0 ustar 00otakar otakar 000000 000000 #########################
use Test::More tests => 10;
BEGIN {
use_ok 'Encode::Arabic::ArabTeX', ':xml';
}
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
can_ok 'Encode::Arabic::ArabTeX', qw 'encode decode encoder decoder';
ok defined &encode, "import Encode's encode() function";
ok defined &decode, "import Encode's decode() function";
$Encode::Mapper::options{'Encode::Arabic::ArabTeX'}{'join'} = undef;
my $encoder = Encode::Arabic::ArabTeX->encoder();
my $decoder = Encode::Arabic::ArabTeX->decoder();
ok defined $Encode::Arabic::ArabTeX::encoder, 'encoder defined';
ok defined $Encode::Arabic::ArabTeX::decoder, 'decoder defined';
my $utf = "\x{0627}\x{0650}\x{0642}\x{0652}\x{0631}\x{064E}\x{0623}\x{0652} " .
"\x{0647}\x{0670}\x{0630}\x{064E}\x{0627} " .
"\x{0671}\x{0644}\x{0646}\x{0651}\x{064E}\x{0635}\x{0651}\x{064E} " .
"\x{0628}\x{0650}\x{0671}\x{0646}\x{0652}\x{062A}\x{0650}\x{0628}\x{064E}\x{0627}\x{0647}\x{064D}. " .
"\x{0643}\x{064E}\x{064A}\x{0652}\x{0641}\x{064E} " .
"\x{0671}\x{0644}\x{0652}\x{062D}\x{064E}\x{0627}\x{0644}\x{064F}\x{061F}";
my $tex = "iqra' h_a_dA an-na.s.sa bi-intibAhiN. kayfa al-.hAlu?";
my $encode = encode "arabtex", $utf;
my $decode = decode "arabtex", $tex;
TODO: {
local $TODO = 'Non-simple mapping';
is $encode, $tex, '$encode is $tex';
# is $decode, $utf, '$decode is $utf';
is $encode, (encode "arabtex", $decode), 'encode(..., $decode) is fine';
# is $decode, (decode "arabtex", $encode), 'decode(..., $encode) is fine';
}
ok ! Encode::is_utf8($encode), "from Perl's internal utf8: " . $encode;
ok Encode::is_utf8($decode), "into Perl's internal utf8: " . encode 'utf8', $decode;
Encode-Arabic-14.1/t/Encode-Arabic-Habash.t 000444 001750 001750 3024 12410623243 20261 0 ustar 00otakar otakar 000000 000000 #########################
use Test::More tests => 5;
BEGIN {
use_ok 'Encode::Arabic::Habash';
}
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
my $utf = "\x{0627}\x{0650}\x{0642}\x{0652}\x{0631}\x{064E}\x{0623}\x{0652} " .
"\x{0647}\x{0670}\x{0630}\x{064E}\x{0627} " .
"\x{0671}\x{0644}\x{0646}\x{0651}\x{064E}\x{0635}\x{0651}\x{064E} " .
"\x{0628}\x{0650}\x{0671}\x{0646}\x{0652}\x{062A}\x{0650}\x{0628}\x{064E}\x{0627}\x{0647}\x{064D}. " .
"\x{0643}\x{064E}\x{064A}\x{0652}\x{0641}\x{064E} " .
"\x{0671}\x{0644}\x{0652}\x{062D}\x{064E}\x{0627}\x{0644}\x{064F}\x{061F}";
my $hsb = encode "utf8", "\x{0041}\x{0069}\x{0071}\x{00B7}\x{0072}\x{0061}\x{00C2}\x{00B7} " .
"\x{0068}\x{00E1}\x{00F0}\x{0061}\x{0041} " .
"\x{00C4}\x{006C}\x{006E}\x{007E}\x{0061}\x{0053}\x{007E}\x{0061} " .
"\x{0062}\x{0069}\x{00C4}\x{006E}\x{00B7}\x{0074}\x{0069}\x{0062}\x{0061}\x{0041}\x{0068}\x{0129}\x{002E} " .
"\x{006B}\x{0061}\x{0079}\x{00B7}\x{0066}\x{0061} " .
"\x{00C4}\x{006C}\x{00B7}\x{0048}\x{0061}\x{0041}\x{006C}\x{0075}\x{003F}";
my $encode = encode "habash", $utf;
my $decode = decode "habash", $hsb;
is $encode, $hsb, '$encode is $hsb';
is $decode, $utf, '$decode is $utf';
is $encode, (encode "habash", $decode), 'encode(..., $decode) is fine';
is $decode, (decode "habash", $encode), 'decode(..., $encode) is fine';
Encode-Arabic-14.1/t/Encode-Mapper-3.t 000444 001750 001750 5331 12410623243 17303 0 ustar 00otakar otakar 000000 000000 #########################
use Test::More tests => 4;
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
use Encode::Mapper; ############################################# Enjoy the ride ^^
use Encode::Mapper ':others', ':silent';
## Types of rules for mapping the data and controlling the engine's configuration #####
@rules = (
'x', 'y', # single 'x' be 'y', unless greediness prefers ..
'xx', 'Y', # .. double 'x' be 'Y' or other rules
'uc(x)x', sub { 'sorry ;)' }, # if 'x' follows 'uc(x)', be sorry, else ..
'uc(x)', [ '', 'X' ], # .. alias this *engine-initial* string
'xuc(x)', [ '', 'xX' ], # likewise, alias for the 'x' prefix
'Xxx', [ sub { $i++; '' }, 'X' ], # count the still married 'x'
);
## Constructors of the engine, i.e. one Encode::Mapper instance #######################
$mapper_A = Encode::Mapper->compile( @rules ); # engine constructor
Encode::Mapper->options('others' => undef, 'silent' => undef, 'complement' => ['x','y','x','z']);
$mapper_B = Encode::Mapper->new( ['others' => sub { shift }, 'silent' => 1], @rules );
is_deeply $mapper_A, $mapper_B, 'constructor identity';
## Elementary performance of the engine ###############################################
@source = ( 'x', 'xAx', 'xBxuc(x)', 'xxx', '', 'xxC' ); # distribution of the data ..
$source = join '', @source; # .. is ignored in this sense
@result_A = ($mapper_A->process(@source), $mapper_A->recover()); # the mapping procedure
@result_B = ($mapper_B->process($source), $mapper_B->recover()); # completely equivalent
is_deeply \@result_A, \@result_B, 'performance identity';
$result = join '', map { ref $_ eq 'CODE' ? $_->() : $_ } @result_A;
is $result, 'YAYByXyC', 'expected output';
is $i, 2, 'expected side effect';
#@follow = $mapper->compute(@source); # follow the engine's computation over @source
#$dumper = $mapper->dumper(); # returns the engine as a Data::Dumper object
## Module's higher API implemented for convenience ####################################
#$encoder = [ $mapper, Encode::Mapper->compile( ... ), ... ]; # reference to mappers
#$result = Encode::Mapper->encode($source, $encoder, 'utf8'); # encode down to 'utf8'
#$decoder = [ $mapper, Encode::Mapper->compile( ... ), ... ]; # reference to mappers
#$result = Encode::Mapper->decode($source, $decoder, 'utf8'); # decode up from 'utf8'
Encode-Arabic-14.1/t/Encode-Mapper-2.t 000444 001750 001750 6142 12410623243 17303 0 ustar 00otakar otakar 000000 000000 #########################
use Test::More tests => 4;
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
use Encode::Mapper; ############################################# Enjoy the ride ^^
use Encode::Mapper ':others', ':silent'; # syntactic sugar for compiler options ..
Encode::Mapper->options ( # .. equivalent, see more in the text
'others' => sub { shift },
'silent' => 1,
);
Encode::Mapper->options ( # .. resetting, but not to use 'use' !!!
'others' => undef,
'silent' => 0
);
## Types of rules for mapping the data and controlling the engine's configuration #####
@rules = (
'x', 'y', # single 'x' be 'y', unless greediness prefers ..
'xx', 'Y', # .. double 'x' be 'Y' or other rules
'uc(x)x', sub { 'sorry ;)' }, # if 'x' follows 'uc(x)', be sorry, else ..
'uc(x)', [ '', 'X' ], # .. alias this *engine-initial* string
'xuc(x)', [ '', 'xX' ], # likewise, alias for the 'x' prefix
'Xxx', [ sub { $i++; '' }, 'X' ], # count the still married 'x'
);
## Constructors of the engine, i.e. one Encode::Mapper instance #######################
$mapper_A = Encode::Mapper->compile( @rules ); # engine constructor
$mapper_B = Encode::Mapper->new( @rules ); # equivalent alias
is_deeply $mapper_A, $mapper_B, 'constructor identity';
## Elementary performance of the engine ###############################################
@source = ( 'x', 'xx', 'xxuc(x)', 'xxx', '', 'xx' ); # distribution of the data ..
$source = join '', @source; # .. is ignored in this sense
@result_A = ($mapper_A->process(@source), $mapper_A->recover()); # the mapping procedure
@result_B = ($mapper_B->process($source), $mapper_B->recover()); # completely equivalent
is_deeply \@result_A, \@result_B, 'performance identity';
$result = join '', map { ref $_ eq 'CODE' ? $_->() : $_ } @result_A;
# maps 'xxxxxuc(x)xxxxx' into ( 'Y', 'Y', '', 'y', CODE(...), CODE(...), 'y' ), ..
# .. then converts it into 'YYyy', setting $i == 2
is $result, 'YYyy', 'expected output';
is $i, 2, 'expected side effect';
#@follow = $mapper->compute(@source); # follow the engine's computation over @source
#$dumper = $mapper->dumper(); # returns the engine as a Data::Dumper object
## Module's higher API implemented for convenience ####################################
#$encoder = [ $mapper, Encode::Mapper->compile( ... ), ... ]; # reference to mappers
#$result = Encode::Mapper->encode($source, $encoder, 'utf8'); # encode down to 'utf8'
#$decoder = [ $mapper, Encode::Mapper->compile( ... ), ... ]; # reference to mappers
#$result = Encode::Mapper->decode($source, $decoder, 'utf8'); # decode up from 'utf8'
Encode-Arabic-14.1/t/Encode-Arabic-Parkinson.t 000444 001750 001750 2162 12410623243 21041 0 ustar 00otakar otakar 000000 000000 #########################
use Test::More tests => 5;
BEGIN {
use_ok 'Encode::Arabic::Parkinson';
}
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
my $utf = "\x{0627}\x{0650}\x{0642}\x{0652}\x{0631}\x{064E}\x{0623}\x{0652} " .
"\x{0647}\x{0670}\x{0630}\x{064E}\x{0627} " .
"\x{0671}\x{0644}\x{0646}\x{0651}\x{064E}\x{0635}\x{0651}\x{064E} " .
"\x{0628}\x{0650}\x{0671}\x{0646}\x{0652}\x{062A}\x{0650}\x{0628}\x{064E}\x{0627}\x{0647}\x{064D}. " .
"\x{0643}\x{064E}\x{064A}\x{0652}\x{0641}\x{064E} " .
"\x{0671}\x{0644}\x{0652}\x{062D}\x{064E}\x{0627}\x{0644}\x{064F}\x{061F}";
my $dil = "AiqoraLo hRvaA Oln~aS~a biOnotibaAhI. kayofa OloHaAlu?";
my $encode = encode "parkinson", $utf;
my $decode = decode "parkinson", $dil;
is $encode, $dil, '$encode is $dil';
is $decode, $utf, '$decode is $utf';
is $encode, (encode "parkinson", $decode), 'encode(..., $decode) is fine';
is $decode, (decode "parkinson", $encode), 'decode(..., $encode) is fine';
Encode-Arabic-14.1/cgi 000755 001750 001750 0 12410623243 14477 5 ustar 00otakar otakar 000000 000000 Encode-Arabic-14.1/cgi/encode 000755 001750 001750 0 12410623243 15734 5 ustar 00otakar otakar 000000 000000 Encode-Arabic-14.1/cgi/encode/index.html 000444 001750 001750 452 12410623243 20047 0 ustar 00otakar otakar 000000 000000
Encode Arabic Online Interface
Encode-Arabic-14.1/cgi/encode/index.fcgi 000555 001750 001750 1043 12410623243 20033 0 ustar 00otakar otakar 000000 000000 #!/usr/bin/perl
# ###################################################################### Otakar Smrz, 2003/01/23
#
# Encode Arabic ################################################################################
use lib '/home/smrz/share/perl/5.10.1',
'/home/smrz/lib/perl5/site_perl/5.10.0', '/home/smrz/lib/perl5/5.10.0',
'/home/smrz/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi',
'/home/smrz/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi/auto';
use Encode::Arabic::CGI;
Encode::Arabic::CGI->new()->run();
Encode-Arabic-14.1/lib 000755 001750 001750 0 12410623243 14503 5 ustar 00otakar otakar 000000 000000 Encode-Arabic-14.1/lib/Encode 000755 001750 001750 0 12410623243 15700 5 ustar 00otakar otakar 000000 000000 Encode-Arabic-14.1/lib/Encode/Mapper.pm 000444 001750 001750 104724 12410623243 17667 0 ustar 00otakar otakar 000000 000000 # ############################################################################ Otakar Smrz, 2003/01/23
#
# Mapper Engine Class ##################################################################### 2003/06/19
package Encode::Mapper;
our $VERSION = '14.1';
use 5.008;
use strict;
use warnings;
use Carp;
use bytes; # ensures splitting into one-byte tokens .. lexically scoped
our %options; # records of options per package .. global register
our %option; # options of the caller package .. used with local
sub import { # enforces setting of options
my $cls = shift @_;
$cls->options(@_) if @_;
}
sub whisper ($) { # module's internal function
carp shift unless $option{'silent'};
}
sub verify_rule ($$) { # module's internal function
unless (defined $_[0] and $_[0] ne '') {
whisper "Rule's LHS is empty, rule ignored";
return;
}
unless (defined $_[1]) {
whisper "Rule's RHS is undefined, rule ignored";
return;
}
if (UNIVERSAL::isa($_[1], 'ARRAY')) {
unless (defined $_[1]->[0]) {
whisper "Rule's RHS is undefined, rule ignored";
return;
}
unless (ref \$_[1]->[0] eq 'SCALAR' or UNIVERSAL::isa($_[1]->[0], 'CODE')) {
whisper "Rule's RHS is neither literal nor subroutine reference, rule ignored";
return;
}
unless (defined $_[1]->[1] and length $_[1]->[1] < length $_[0]) {
whisper "Rule type '\$A => [\$X, \$Y], length \$A > length \$Y' misused, considering it '\$A => \$X'";
$_[1] = $_[1]->[0];
}
}
elsif (ref \$_[1] ne 'SCALAR' and not UNIVERSAL::isa($_[1], 'CODE')) {
whisper "Rule's RHS is neither literal nor subroutine reference, rule ignored";
return;
}
return 1;
}
sub options ($%) { # options for general compilation of Mappers
my $cls = shift @_;
my ($i, $opt, %opt);
my $caller = caller 0; $caller = caller 1 if $caller eq __PACKAGE__;
my @returns = exists $options{$caller} ? %{$options{$caller}} : ();
while (@_) {
$opt = lc shift @_;
if ($opt =~ /^\:/) {
$opt eq ':others' and $opt{'others'} = sub { shift } and next;
$opt eq ':silent' and $opt{'silent'} = 1 and next;
$opt eq ':join' and $opt{'join'} = '';
}
else {
$opt =~ /^\-*(.*)$/;
$opt{$1} = shift @_;
}
}
{
local $option{'silent'} = exists $opt{'silent'} ? $opt{'silent'} : $options{$caller}{'silent'};
if (defined $opt{'complement'} and UNIVERSAL::isa($opt{'complement'}, 'ARRAY')) {
for ($i = 0; $i < @{$opt{'complement'}}; $i += 2) {
verify_rule $opt{'complement'}->[$i], $opt{'complement'}->[$i + 1];
}
}
if (defined $opt{'override'} and UNIVERSAL::isa($opt{'override'}, 'ARRAY')) {
for ($i = 0; $i < @{$opt{'override'}}; $i += 2) {
verify_rule $opt{'override'}->[$i], $opt{'override'}->[$i + 1];
}
}
if (defined $opt{'others'} and not $option{'silent'}) { # see whisper
if (UNIVERSAL::isa($opt{'others'}, 'CODE')) {
carp "The subroutine will be called with the 'other' LHS parameter to get the rule's RHS";
}
else {
carp "The scalar value will become the RHS of each 'other' LHS";
}
}
}
return %opt unless defined $cls;
$options{$caller}{$_} = $opt{$_} foreach keys %opt;
return @returns;
}
*new = *compile{'CODE'}; # provides the 'new' constructor .. the 'compile' method
# *new = \&compile; # might be known at compile-time
sub compile ($@) { # returns Mapper .. modified Aho-Corasick and Boyer-Moore search engine
my $cls = shift @_;
my (@tree, @bell, @skip, @queue, %redef);
my ($q, $r, $s, $t, $i, $token, $trick);
my ($null_list, $null_hash) = ([], {}); # references to empties need not consume unique memory
my ($no_code, $no_list) = (1, 1); # optimization indicators
local %option = exists $options{caller 0} ? %{$options{caller 0}} : ();
# options be local due to verify_rule and whisper
if (UNIVERSAL::isa($_[0], 'ARRAY')) {
%option = (%option, options undef, @{shift @_});
}
elsif (UNIVERSAL::isa($_[0], 'HASH')) {
%option = (%option, options undef, %{shift @_});
}
$skip[0] = undef; # never ever used .. fix the number of list elements equal
$bell[0] = $null_list; # important .. depth-wise inheritation of the lists
if (defined $option{'complement'}) {
for ($i = 0; $i < @{$option{'complement'}}; $i += 2) {
$q = 0;
foreach $token (split //, $option{'complement'}->[$i]) {
$tree[$q]->{$token} = ++$r unless defined $tree[$q]->{$token}; # increment $r ^^
$q = $tree[$q]->{$token};
}
$tree[$q] = {} unless defined $tree[$q]; # define trees correctly, economize below
whisper "Redefining the mapping for '" . $option{'complement'}->[$i] . "'" if defined $bell[$q];
$bell[$q] = [ $option{'complement'}->[$i + 1] ];
}
}
for ($i = 0; $i < @_; $i += 2) { # generate $tree[$q] transition function and initial $bell[$q]
next unless verify_rule $_[$i], $_[$i + 1];
$q = 0;
foreach $token (split //, $_[$i]) {
$tree[$q]->{$token} = ++$r unless defined $tree[$q]->{$token}; # increment $r ^^
$q = $tree[$q]->{$token};
}
$tree[$q] = {} unless defined $tree[$q]; # define trees correctly, economize below
whisper "Redefining the mapping for '$_[$i]'" if $redef{$q}++;
$bell[$q] = [ $_[$i + 1] ];
}
if (defined $option{'override'}) {
for ($i = 0; $i < @{$option{'override'}}; $i += 2) {
$q = 0;
foreach $token (split //, $option{'override'}->[$i]) {
$tree[$q]->{$token} = ++$r unless defined $tree[$q]->{$token}; # increment $r ^^
$q = $tree[$q]->{$token};
}
$tree[$q] = {} unless defined $tree[$q]; # define trees correctly, economize below
whisper "Redefining the mapping for '" . $option{'override'}->[$i] . "'" if $redef{$q}++;
$bell[$q] = [ $option{'override'}->[$i + 1] ];
}
}
foreach $token (map { chr } 0x00..0xFF) {
unless (defined $tree[0]->{$token}) {
unless (defined $option{'others'}) {
$tree[0]->{$token} = 0;
}
else {
$tree[0]->{$token} = ++$r; # increment $r ^^
$tree[$r] = {}; # define trees correctly
}
}
$q = $tree[0]->{$token}; # including existing prefixes
unless ($q == 0) {
unless (defined $bell[$q]) {
if (not defined $option{'others'}) {
$bell[$q] = $bell[0];
}
elsif (UNIVERSAL::isa($option{'others'}, 'CODE')) {
$bell[$q] = [ $option{'others'}->($token) ];
}
else {
$bell[$q] = [ $option{'others'} ];
}
}
$skip[$q] = 0;
push @queue, $q;
}
}
while (@queue) { # generate $skip[$q] backward function and complete $bell[$q]
$q = shift @queue;
foreach $token (keys %{$tree[$q]}) {
$t = $tree[$q]->{$token};
push @queue, $t;
if (defined $bell[$t]) {
$skip[$t] = 0;
if (UNIVERSAL::isa($bell[$t]->[0], 'ARRAY')) { # shortening property of the rules
$s = $skip[$t];
foreach $trick (split //, $bell[$t]->[0]->[1]) {
until (defined $tree[$s]->{$trick}) { # loops only if not in the root ^^
push @{$bell[$t]}, @{$bell[$s]};
$s = $skip[$s];
}
$s = $tree[$s]->{$trick};
}
$skip[$t] = $s;
$bell[$t]->[0] = $bell[$t]->[0]->[0];
}
}
else {
$s = $skip[$q];
$bell[$t] = [ @{$bell[$q]} ]; # unique reference quite important ^^
until (defined $tree[$s]->{$token}) { # extremely tricky ...
push @{$bell[$t]}, @{$bell[$s]};
$s = $skip[$s];
}
$skip[$t] = $tree[$s]->{$token};
}
}
$tree[$q] = $null_hash unless keys %{$tree[$q]}; # economize with memory
}
for ($q = 1; $q < @bell; $q++) { # optimize the bell function for $q > 0
if (grep { UNIVERSAL::isa($_, 'CODE') } @{$bell[$q]}) {
$no_code = 0;
}
elsif (defined $option{'join'}) {
$bell[$q] = join $option{'join'}, @{$bell[$q]};
next;
}
if (@{$bell[$q]} == 1) {
$bell[$q] = $bell[$q]->[0];
}
else {
$bell[$q] = $null_list if @{$bell[$q]} == 0;
$no_list = 0;
}
}
return bless {
'current' => 0,
'tree' => \@tree,
'bell' => \@bell,
'skip' => \@skip,
'null' => { 'list' => $null_list, 'hash' => $null_hash },
'join' => $option{'join'},
'no_code' => $no_code,
'no_list' => $no_list,
}, $cls;
}
sub process ($@) { # returns the list of search results performed by Mapper
my $obj = shift @_;
my (@returns, $phrase, $token, $q);
$q = $obj->{'current'};
if ($obj->{'no_list'}) {
foreach $phrase (@_) {
foreach $token (split //, $phrase) {
until (defined $obj->{'tree'}[$q]->{$token}) {
push @returns, $obj->{'bell'}[$q];
$q = $obj->{'skip'}[$q];
}
$q = $obj->{'tree'}[$q]->{$token};
}
}
}
else {
foreach $phrase (@_) {
foreach $token (split //, $phrase) {
until (defined $obj->{'tree'}[$q]->{$token}) {
push @returns, ref $obj->{'bell'}[$q] eq 'ARRAY' ?
@{$obj->{'bell'}[$q]} : $obj->{'bell'}[$q];
$q = $obj->{'skip'}[$q];
}
$q = $obj->{'tree'}[$q]->{$token};
}
}
}
$obj->{'current'} = $q;
return @returns;
}
sub recover ($;$$) { # returns the 'in-progress' search result and resets Mapper
my ($obj, $r, $q) = @_;
my (@returns);
$q = $obj->{'current'} unless defined $q;
if ($obj->{'no_list'}) {
until ($q == 0) {
push @returns, $obj->{'bell'}[$q];
$q = $obj->{'skip'}[$q];
}
}
else {
until ($q == 0) {
push @returns, ref $obj->{'bell'}[$q] eq 'ARRAY' ?
@{$obj->{'bell'}[$q]} : $obj->{'bell'}[$q];
$q = $obj->{'skip'}[$q];
}
}
$obj->{'current'} = defined $r ? $r : 0;
return @returns;
}
sub compute ($@) {
my $obj = shift @_;
my (@returns, $phrase, $token, $q);
$obj->recover();
foreach $phrase (@_) {
foreach $token (split //, $phrase) {
push @returns, [$token, $obj->{'current'}];
push @{$returns[-1]}, [$obj->process($token)];
$q = $obj->{'current'};
push @{$returns[-1]}, $q, $obj->{'bell'}[$q], $obj->{'skip'}[$q];
}
}
push @returns, ['recover', $obj->{'current'}];
push @{$returns[-1]}, [$obj->recover()];
$q = $obj->{'current'};
push @{$returns[-1]}, $q, $obj->{'bell'}[$q], ($q == 0 ? 'undef' : $obj->{'skip'}[$q]);
return @returns;
}
sub dumper ($;$) {
my ($obj, $ref) = @_;
$ref = ['L', 'H', 'mapper'] unless defined $ref;
require Data::Dumper;
return Data::Dumper->new([$obj->{'null'}{'list'}, $obj->{'null'}{'hash'}, $obj], $ref);
}
sub describe ($;$) {
my ($obj, $ref) = @_;
my ($q, $nodes, $edges, $skips, $bells, $paths, $lists);
$nodes = @{$obj->{'tree'}};
$edges = [];
$lists = [];
if ($obj->{'no_list'}) {
for ($q = 0; $q < @{$obj->{'tree'}}; $q++) {
$lists->[$q * 3] = scalar %{$obj->{'tree'}[$q]};
$lists->[$q * 3] =~ m{^([0-9]+)(?:/([0-9]+))?$};
$edges->[0] += scalar keys %{$obj->{'tree'}[$q]};
$lists->[$q * 3] .= " " . keys %{$obj->{'tree'}[$q]};
if (defined $2) {
$edges->[1] += $1;
$edges->[2] += $2;
}
else {
$paths++ unless $1;
}
$lists->[$q * 3 + 1] = $obj->{'bell'}[$q] eq "" ? 0 : 1;
$bells += $lists->[$q * 3 + 1];
next if $q == 0;
$lists->[$obj->{'skip'}[$q] * 3 + 2]++;
$skips++ unless $obj->{'skip'}[$q] == 0;
}
}
else {
for ($q = 0; $q < @{$obj->{'tree'}}; $q++) {
$lists->[$q * 3] = scalar %{$obj->{'tree'}[$q]};
$lists->[$q * 3] =~ m{^([0-9]+)(?:/([0-9]+))?$};
$edges->[0] += scalar keys %{$obj->{'tree'}[$q]};
$lists->[$q * 3] .= " " . keys %{$obj->{'tree'}[$q]};
if (defined $2) {
$edges->[1] += $1;
$edges->[2] += $2;
}
else {
$paths++ unless $1;
}
$lists->[$q * 3 + 1] = ref $obj->{'bell'}[$q] eq 'ARRAY' ? scalar @{$obj->{'bell'}[$q]} : 1;
$bells += $lists->[$q * 3 + 1];
next if $q == 0;
$lists->[$obj->{'skip'}[$q] * 3 + 2]++;
$skips++ unless $obj->{'skip'}[$q] == 0;
}
}
my $return = {'nodes' => $nodes, 'edges' => $edges->[0], 'slots' => $edges->[1] . "/" . $edges->[2],
'skips' => $skips, 'bells' => $bells, 'paths' => $paths, 'lists' => $lists};
if (defined $ref) {
$ref = *STDERR if ref $ref ne 'GLOB';
print $ref ( join ", ", map { ( defined $return->{$_} ? $return->{$_} : 'undef' ) . " " . $_ }
grep { $_ ne 'lists' } keys %{$return} ) . "\n";
}
return $return;
}
sub encode ($$$;$) {
my ($cls, $text, $encoder, $enc) = @_;
my ($mapper, $join);
local %option = exists $options{caller 0} ? %{$options{caller 0}} : ();
# options be local due to whisper
require Encode;
unless (Encode::is_utf8($text)) {
whisper "The input text is not in Perl's internal utf8 .. note only, might be fine";
}
if ($enc) {
unless (Encode::resolve_alias($enc)) {
carp "Cannot resolve the proposed '$enc' encoding";
return undef;
}
$text = Encode::encode($enc, $text);
}
if (not UNIVERSAL::isa($encoder, 'ARRAY') or grep { defined $_ and not $_->isa($cls) } @{$encoder}) {
carp "Expecting a reference to an array of '$cls' objects";
return undef;
}
foreach $mapper (@{$encoder}) {
last unless defined $mapper;
$join = defined $mapper->{'join'} ? $mapper->{'join'} :
defined $option{'join'} ? $option{'join'} : "";
if ($mapper->{'no_code'}) {
$text = join $join, $mapper->process($text), $mapper->recover();
}
else {
$text = join $join, map {
UNIVERSAL::isa($_, 'CODE') ? $_->() : $_
} $mapper->process($text), $mapper->recover();
}
}
return $text;
}
sub decode ($$$;$) {
my ($cls, $text, $decoder, $enc) = @_;
my ($mapper, $join);
local %option = exists $options{caller 0} ? %{$options{caller 0}} : ();
# options be local due to tradition ^^
require Encode;
$enc = 'utf8' unless $enc;
unless (Encode::resolve_alias($enc)) {
carp "Cannot resolve the proposed '$enc' encoding";
return undef;
}
if (not UNIVERSAL::isa($decoder, 'ARRAY') or grep { defined $_ and not $_->isa($cls) } @{$decoder}) {
carp "Expecting a reference to an array of $cls objects";
return undef;
}
foreach $mapper (@{$decoder}) {
last unless defined $mapper;
$join = defined $mapper->{'join'} ? $mapper->{'join'} :
defined $option{'join'} ? $option{'join'} : "";
if ($mapper->{'no_code'}) {
$text = join $join, $mapper->process($text), $mapper->recover();
}
else {
$text = join $join, map {
UNIVERSAL::isa($_, 'CODE') ? $_->() : $_
} $mapper->process($text), $mapper->recover();
}
}
return Encode::is_utf8($text) ? $text : Encode::decode($enc, $text);
}
1;
__END__
=head1 NAME
Encode::Mapper - Rewrite rules compiler and interpreter
=head1 SYNOPSIS
use Encode::Mapper; ############################################# Enjoy the ride ^^
use Encode::Mapper ':others', ':silent'; # syntactic sugar for compiler options ..
Encode::Mapper->options ( # .. equivalent, see more in the text
'others' => sub { shift },
'silent' => 1,
);
Encode::Mapper->options ( # .. resetting, but not to use 'use' !!!
'others' => undef,
'silent' => 0
);
## Types of rules for mapping the data and controlling the engine's configuration #####
@rules = (
'x', 'y', # single 'x' be 'y', unless greediness prefers ..
'xx', 'Y', # .. double 'x' be 'Y' or other rules
'uc(x)x', sub { 'sorry ;)' }, # if 'x' follows 'uc(x)', be sorry, else ..
'uc(x)', [ '', 'X' ], # .. alias this *engine-initial* string
'xuc(x)', [ '', 'xX' ], # likewise, alias for the 'x' prefix
'Xxx', [ sub { $i++; '' }, 'X' ], # count the still married 'x'
);
## Constructors of the engine, i.e. one Encode::Mapper instance #######################
$mapper = Encode::Mapper->compile( @rules ); # engine constructor
$mapper = Encode::Mapper->new( @rules ); # equivalent alias
## Elementary performance of the engine ###############################################
@source = ( 'x', 'xx', 'xxuc(x)', 'xxx', '', 'xx' ); # distribution of the data ..
$source = join '', @source; # .. is ignored in this sense
@result = ($mapper->process(@source), $mapper->recover()); # the mapping procedure
@result = ($mapper->process($source), $mapper->recover()); # completely equivalent
$result = join '', map { ref $_ eq 'CODE' ? $_->() : $_ } @result;
# maps 'xxxxxuc(x)xxxxx' into ( 'Y', 'Y', '', 'y', CODE(...), CODE(...), 'y' ), ..
# .. then converts it into 'YYyy', setting $i == 2
@follow = $mapper->compute(@source); # follow the engine's computation over @source
$dumper = $mapper->dumper(); # returns the engine as a Data::Dumper object
## Module's higher API implemented for convenience ####################################
$encoder = [ $mapper, Encode::Mapper->compile( ... ), ... ]; # reference to mappers
$result = Encode::Mapper->encode($source, $encoder, 'utf8'); # encode down to 'utf8'
$decoder = [ $mapper, Encode::Mapper->compile( ... ), ... ]; # reference to mappers
$result = Encode::Mapper->decode($source, $decoder, 'utf8'); # decode up from 'utf8'
=head1 ABSTRACT
Encode::Mapper serves for intuitive, yet efficient construction of mappings for Encode.
The module finds direct application in Encode::Arabic. It provides an object-oriented
programming interface to convert data consistently, follow the engine's computation,
dump the engine using Data::Dumper, etc.
=head1 DESCRIPTION
It looks like the author of the extension ... ;) preferred giving formal and terse examples to
writing English. Please, see L where L
is used for solving complex real-world problems.
=head2 INTRO AND RULE TYPES
The module's core is an algoritm which, from the rules given by the user, builds a finite-state
transducer, i.e. an engine performing greedy search in the input stream and producing output
data and side effects relevant to the results of the search. Transducers may be linked one with
another, thus forming multi-level devices suitable for nontrivial encoding/decoding tasks.
The rules declare which input sequences of L to search for, and what to do upon their
occurence. If the left-hand side (LHS) of a rule is the longest left-most string out of those
applicable on the input, the righ-hand side (RHS) of the rule is evaluated. The RHS defines the
corresponding output string, and possibly controls the engine as if the extra text were prepended
before the rest of the input:
$A => $X # $A .. literal string
# $X .. literal string or subroutine reference
$A => [$X, $Y] # $Y .. literal string for which 'length $Y < length $A'
The order of the rules does not matter, except when several rules with the same LHS are stated.
In such a case, redefinition warning is usually issued before overriding the RHS.
=head2 LOW-LEVEL METHODS
=over
=item compile (I<$class,> @rules)
=item compile (I<$class,> $opts, @rules)
The constructor of an L instance. The first argument is the name of the
class, the rest is the list of rules ... LHS odd elements, RHS even elements, unless the first element
is a reference to an array or a hash, which then becomes C<$opts>.
If C<$opts> is recognized, it is used to modify the compiler C locally for the engine being
constructed. If an option is not overridden, its global setting holds.
The compilation algorithm, and the search algorithm itself, were inspired by Aho-Corasick and Boyer-Moore
algorithms, and by the studies of finite automata with the restart operation. The engine is implemented
in the classical sense, using hashes for the transition function for instance. We expect to improve this
to Perl code evaluation, if the speed-up is significant.
It is to explore the way Perl's regular expressions would cope with the task, i.e. verify our initial
doubts which prevented us from trying. Since L's functionality is much
richer than pure search, simulating it completely might be resource-expensive and non-elegant. Therefore,
experiment reports are welcome.
=item new (I<$class,> @list)
Name alias to the C constructor.
=item process (I<$obj,> @list)
Process the input list with the engine. There is no resetting within the call of the method. Internally,
the text in the list is C into L, and there is just no need for the user to C
his/hers strings or lines of data. Note the unveiled properties of the L
class as well:
sub process ($@) { # returns the list of search results performed by Mapper
my $obj = shift @_;
my (@returns, $phrase, $token, $q);
use bytes; # ensures splitting into one-byte tokens
$q = $obj->{'current'};
foreach $phrase (@_) {
foreach $token (split //, $phrase) {
until (defined $obj->{'tree'}[$q]->{$token}) {
push @returns, @{$obj->{'bell'}[$q]};
$q = $obj->{'skip'}[$q];
}
$q = $obj->{'tree'}[$q]->{$token};
}
}
$obj->{'current'} = $q;
return @returns;
}
=item recover (I<$obj,> $r, $q)
Since the search algorithm is greedy and the engine does not know when the end of the data comes,
there must be a method to tell. Normally, C is called on the object without the other two
optional parameters setting the initial and the final state, respectively.
sub recover ($;$$) { # returns the 'in-progress' search result and resets Mapper
my ($obj, $r, $q) = @_;
my (@returns);
$q = $obj->{'current'} unless defined $q;
until ($q == 0) {
push @returns, @{$obj->{'bell'}[$q]};
$q = $obj->{'skip'}[$q];
}
$obj->{'current'} = defined $r ? $r : 0;
return @returns;
}
=item compute (I<$obj,> @list)
Tracks down the computation over the list of data, resetting the engine before and after to its
initial state. Developers might like this ;)
local $\ = "\n"; local $, = ":\t"; # just define the display
foreach $result ($mapper->compute($source)) { # follow the computation
print "Token" , $result->[0];
print "Source" , $result->[1];
print "Output" , join " + ", @{$result->[2]};
print "Target" , $result->[3];
print "Bell" , join ", ", @{$result->[4]};
print "Skip" , $result->[5];
}
=item dumper (I<$obj,> $ref)
The individual instances of L can be stored as revertible data
structures. For minimalistic reasons, dumping needs to include explicit short-identifier
references to the empty array and the empty hash of the engine. For details, see
L.
sub dumper ($;$) {
my ($obj, $ref) = @_;
$ref = ['L', 'H', 'mapper'] unless defined $ref;
require Data::Dumper;
return Data::Dumper->new([$obj->{'null'}{'list'}, $obj->{'null'}{'hash'}, $obj], $ref);
}
=item describe (I<$obj,> $ref)
Describes the L object and returns a hash of the characteristics.
If C<$ref> is defined, the information is also Ced into the C<$ref>erenced stream, or to
C if C<$ref> is not a filehandle.
=back
=head2 HIGH-LEVEL METHODS
In the L world, one can work with different encodings and is also provided a function
for telling if the data are in Perl's internal utf8 format or not. In the
L business, one is encouraged to compile different mappers and stack
them on top of each other, getting an easy-to-work-with filtering device.
In combination, this module offers the following C and C methods. In their prototypes,
C<$encoder>/C<$decoder> represent merely a reference to an array of mappers, although mathematics might
do more than that in future implementations ;)
Currently, the mappers involved are not reset with C before the computation. See the C<--join>
option for more comments on the code:
foreach $mapper (@{$_[2]}) { # either $encoder or $decoder
$join = defined $mapper->{'join'} ? $mapper->{'join'} :
defined $option{'join'} ? $option{'join'} : "";
$text = join $join, map {
UNIVERSAL::isa($_, 'CODE') ? $_->() : $_
} $mapper->process($text), $mapper->recover();
}
=over
=item encode (I<$class,> $text, $encoder, $enc)
If C<$enc> is defined, the C<$text> is encoded into that encoding, using L. Then, the
C<$encoder>'s engines are applied in series on the data. The returned text should have the utf8
flag off.
=item decode (I<$class,> $text, $decoder, $enc)
The C<$text> is run through the sequence of engines in C<$decoder>. If the result does not have the
utf8 flag on, decoding from C<$enc> is further performed by L. If C<$enc> is not defined,
utf8 is assumed.
=back
=head2 OPTIONS AND EXPORT
The language the L engine works on is not given exclusively by the rules
passed as parameters to the C or C constructor methods. The nature of the compilation is
influenced by the current setting of the following options:
=over
=item --complement
This option accepts a reference to an array declaring rules which are to complement the rules of
the constructor. Redefinition warnings are issued only if you redefine within the option's list,
not when a rule happens to be overridden during compilation.
=item --override
Overrides the rules of the constructor. Redefinition warnings are issued, though. You might, for
example, want to preserve all XML markup in the data you are going to process through your
encoders/decoders:
'override' => [ # override rules of these LHS .. there's no other tricks ^^
( # combinations of '<' and '>' with the other bytes
map {
my $x = chr $_;
"<" . $x, [ "<" . $x, ">" ], # propagate the '>' sign implying ..
">" . $x, [ $x, ">" ], # .. preservation of the bytes
} 0x00..0x3B, 0x3D, 0x3F..0xFF
),
">>", ">", # stop the whole process ..
"<>", "<>", # .. do not even start it
"><", [ "<", ">" ], # rather than nested '<' and '>', ..
"<<", [ "<<", ">" ],
">\\<", [ "<", ">" ], # .. prefer these escape sequences
">\\\\", [ "\\", ">" ],
">\\>", [ ">", ">" ],
">", ">", # singular symbols may migrate right ..
"<", "<", # .. or preserve the rest of the data
]
=item --others
If defined, this option controls how to deal with 'others', i.e. bytes of input for which there is no
rule, by defining rules for them. In case this option gets a code reference, the referenced subroutine
will be called with the 'other' LHS parameter to get the rule's RHS. Otherwise, a defined scalar value
will become the RHS of each 'other' LHS.
To preserve the 'other' bytes, you can use
'others' => sub { shift } # preserve every non-treated byte
the effect of which is similar to including the C