Encode-Arabic-14.1000755001750001750 012410623243 13735 5ustar00otakarotakar000000000000Encode-Arabic-14.1/MANIFEST000444001750001750 151212410623243 15222 0ustar00otakarotakar000000000000bin/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/LICENSE000444001750001750 10451312410623243 15143 0ustar00otakarotakar000000000000 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.PL000444001750001750 130312410623243 15363 0ustar00otakarotakar000000000000use 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.yml000444001750001750 275012410623243 15347 0ustar00otakarotakar000000000000--- 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/README000444001750001750 163112410623243 14753 0ustar00otakarotakar000000000000Encode 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.json000444001750001750 451312410623243 15516 0ustar00otakarotakar000000000000{ "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/t000755001750001750 012410623243 14200 5ustar00otakarotakar000000000000Encode-Arabic-14.1/t/Encode-Arabic.t000444001750001750 236712410623243 17106 0ustar00otakarotakar000000000000######################### 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.t000444001750001750 43612410623243 20651 0ustar00otakarotakar000000000000######################### 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.t000444001750001750 232512410623243 17304 0ustar00otakarotakar000000000000######################### 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.t000444001750001750 337112410623243 21125 0ustar00otakarotakar000000000000######################### 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.t000444001750001750 362712410623243 22141 0ustar00otakarotakar000000000000######################### 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.t000444001750001750 267612410623243 21212 0ustar00otakarotakar000000000000######################### 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.t000444001750001750 530512410623243 17302 0ustar00otakarotakar000000000000######################### 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.t000444001750001750 44412410623243 21407 0ustar00otakarotakar000000000000######################### 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.t000444001750001750 347212410623243 20370 0ustar00otakarotakar000000000000######################### 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.t000444001750001750 302412410623243 20261 0ustar00otakarotakar000000000000######################### 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.t000444001750001750 533112410623243 17303 0ustar00otakarotakar000000000000######################### 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.t000444001750001750 614212410623243 17303 0ustar00otakarotakar000000000000######################### 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.t000444001750001750 216212410623243 21041 0ustar00otakarotakar000000000000######################### 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/cgi000755001750001750 012410623243 14477 5ustar00otakarotakar000000000000Encode-Arabic-14.1/cgi/encode000755001750001750 012410623243 15734 5ustar00otakarotakar000000000000Encode-Arabic-14.1/cgi/encode/index.html000444001750001750 45212410623243 20047 0ustar00otakarotakar000000000000 Encode Arabic Online Interface Encode-Arabic-14.1/cgi/encode/index.fcgi000555001750001750 104312410623243 20033 0ustar00otakarotakar000000000000#!/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/lib000755001750001750 012410623243 14503 5ustar00otakarotakar000000000000Encode-Arabic-14.1/lib/Encode000755001750001750 012410623243 15700 5ustar00otakarotakar000000000000Encode-Arabic-14.1/lib/Encode/Mapper.pm000444001750001750 10472412410623243 17667 0ustar00otakarotakar000000000000# ############################################################################ 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 to the C<--complement> rules: 'complement' => [ ( map { ( chr $_ ) x 2 } 0x00..0xFF ), ... ] # ... is your rules You may of course wish to return undefined values if there are any non-treated bytes in the input. In order for the C to be a correct RHS, you have to protect it once more by the C like this: 'others' => sub { sub { undef } } =item --silent Setting it to a true value will prevent any warnings issued during the engine's compilation, mostly reflecting an incorrect or dubious use of a rule. =item --join This option enables less memory-requiring representation of the engines. If this option is defined when the constructor is called, the setting is stored in the instance internally. Any lists of literal RHS which are to be emitted simultaneously from the engine are joined into a string with the option's value, empty lists turn into empty strings. If an engine was compiled with this option defined, the value will be used to join output of C and C, too. If not, either the current value of the option or the empty string will help instead. =back The keywords of options can be in mixed case and/or start with any number of dashes, and the next element in the list is taken as the option's value. There are special keywords, however, beginning with a colon and not gulping down the next element: =over =item :others Equivalent to the code C<< 'others' => sub { shift } >> explained above. =item :silent Equivalent to C<< 'silent' => 1 >>, or rather to the maximum silence if more degrees of it are introduced in the future. =item :join Equivalent to C<< 'join' => '' >>. Use this option if you are going to dump and load the new engine often, and if you do not miss the list-supporting uniformity of C and C. =back Compiler options are associated with package names in the C<%Encode::Mapper::options> variable, and confined to them. While C and C perform the setting with respect to the caller package, accessing the hash directly is neither recommended, nor restricted. There is a nice compile-time invocation of C with the CC< Encode::Mapper LIST> idiom, which you might prefer to explicit method calls. Local modification of the package's global setting that applies just to the engine being constructed is done by supplying the options as an extra parameter to C. 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 }, # ) =over =item options (I<$class,> @list) If C<$class> is defined, enforces the options in the list globally for the calling package. The return value of this method is the state of the options before the proposed changes were set. If C<$class> is undefined, nothing is set, only the canonized forms of the declared keywords and their values are returned. =item import (I<$class,> @list) This module does not export any symbols. This method just calls C, provided there are some elements in the list. =back =head1 SEE ALSO There are related theoretical studies which the implementation may have touched. You might be interested in Aho-Corasick and Boyer-Moore algorithms as well as in finite automata with the restart operation. L, L, L Encode Arabic: Exercise in Functional Parsing L =head1 AUTHOR Otakar Smrz C<< >>, L =head1 COPYRIGHT AND LICENSE 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. =cut Encode-Arabic-14.1/lib/Encode/Arabic.pm000444001750001750 1563112410623243 17602 0ustar00otakarotakar000000000000# ###################################################################### Otakar Smrz, 2003/01/23 # # Encodings of Arabic ########################################################################## package Encode::Arabic; our $VERSION = '14.1'; use 5.008; use strict; use warnings; use Carp; sub import { # perform import as if Encode were used one level before this module if (defined $_[1] and $_[1] eq ':modes') { require Exporter; our @ISA = qw 'Exporter'; our @EXPORT_OK = qw 'enmode demode'; __PACKAGE__->export_to_level(1, $_[0], 'enmode', 'demode'); splice @_, 1, 1; } require Encode; push @Encode::ISA, 'Exporter' unless Encode->can('export_to_level'); Encode->export_to_level(1, @_); } use lib '..'; use Encode::Arabic::ArabTeX; use Encode::Arabic::ArabTeX::RE; use Encode::Arabic::ArabTeX::Verbatim; use Encode::Arabic::ArabTeX::ZDMG; use Encode::Arabic::ArabTeX::ZDMG::RE; use Encode::Arabic::Buckwalter; use Encode::Arabic::Parkinson; use Encode::Arabic::Habash; sub enmode ($@) { my $enc = shift; my $obj = Encode::find_encoding($enc); croak "Unknown encoding '$enc'" unless defined $obj; $obj->enmode(@_); } sub demode ($@) { my $enc = shift; my $obj = Encode::find_encoding($enc); croak "Unknown encoding '$enc'" unless defined $obj; $obj->demode(@_); } 1; __END__ =head1 NAME Encode::Arabic - Encodings of Arabic =head1 SYNOPSIS use Encode::Arabic; # imports just like 'use Encode' even with options would while ($line = <>) { # renders the ArabTeX notation for Arabic both in the .. print encode 'utf8', decode 'arabtex', $line; # .. Arabic script proper and the print encode 'utf8', decode 'arabtex-zdmg', $line; # .. Latin phonetic transcription } # 'use Encode::Arabic ":modes"' would export the functions controlling the conversion modes Encode::Arabic::demode 'arabtex', 'default'; Encode::Arabic::enmode 'buckwalter', 'full', 'xml', 'strip off kashida'; # Arabic in lower ASCII transliterations <--> Arabic script in Perl's internal encoding $string = decode 'ArabTeX', $octets; $octets = encode 'Buckwalter', $string; $string = decode 'Buckwalter', $octets; $octets = encode 'ArabTeX', $string; # Arabic in lower ASCII transliterations <--> Latin phonetic transcription, Perl's utf8 $string = decode 'Buckwalter', $octets; $octets = encode 'ArabTeX', $string; $string = decode 'ArabTeX-ZDMG', $octets; $octets = encode 'utf8', $string; =head1 DESCRIPTION This module is a wrapper for various implementations of the encoding systems used for the Arabic language and covering even some non-Arabic extensions to the Arabic script. The included modules fit in the philosophy of L and can be used directly with the L module. =head2 LIST OF ENCODINGS =over =item ArabTeX ArabTeX multi-character notation for Arabic / Perl's internal format for the Arabic script L, uses L =item ArabTeX-RE Deprecated method using sequential regular-expression substitutions. Limited in scope over the ArabTeX notation and non-efficient in data processing, still, not requiring the L module. L =item ArabTeX-Verbatim ArabTeX multi-character I notation for Arabic / Perl's internal format for the Arabic script L, uses L =item ArabTeX-ZDMG ArabTeX multi-character notation for Arabic / Perl's internal format for the Latin phonetic trascription in the ZDMG style L, uses L =item ArabTeX-ZDMG-RE Deprecated method using sequential regular-expression substitutions. Limited in scope over the ArabTeX notation and non-efficient in data processing, still, not requiring the L module. L =item Buckwalter Buckwalter one-to-one notation for Arabic / Perl's internal format for the Arabic script L =item Parkinson Parkinson one-to-one notation for Arabic / Perl's internal format for the Arabic script L =item Habash Habash-Soudi-Buckwalter one-to-one notation for Arabic / Perl's internal format for the Arabic script L =back There are generic aliases to these provided by L. Case does not matter and all characters of the class C<[ _-]> are interchangable. Note that the standard L module already deals with several other single-byte encoding schemes for Arabic popular with whichever operating system, be it *n*x, Windows, DOS or Macintosh. See L and L for their identification names and aliases. =head2 EXPORTS & MODES The module exports as if C also appeared in the calling package. The C options are just delegated to L and imports performed properly, with the exception of the C<:modes> option coming first in the list. In such a case, the following functions will be introduced into the namespace of the importing package: =over =item enmode ($enc, @list) Calls the C method associated with the given C<$enc> encoding, and passes the C<@list> to it. The idea is similar to the C functions and methods of the L and L modules, respectively. Used for control over the modes of conversion. =item demode ($enc, @list) Analogous to C, but calling the appropriate C method. See the individual implementations of the listed encodings. =back =head1 SEE ALSO Encode::Arabic Online Interface L Encode Arabic Project L ElixirFM Online Interface L ElixirFM Project L L, L, L, L L L L, L L =head1 AUTHOR Otakar Smrz C<< >>, L =head1 COPYRIGHT AND LICENSE 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. =cut Encode-Arabic-14.1/lib/Encode/Arabic000755001750001750 012410623243 17061 5ustar00otakarotakar000000000000Encode-Arabic-14.1/lib/Encode/Arabic/Exec.pm000444001750001750 1001212410623243 20452 0ustar00otakarotakar000000000000# ########################################################################## Otakar Smrz, 2009/03/21 # # Encode Arabic Executable ######################################################################### package Encode::Arabic::Exec; our $VERSION = '14.1'; use strict; use Encode; use File::Spec; use File::Temp; use File::Which; our $encode = 'encode'; our $decode = 'decode'; our %encode = (); our %decode = (); sub import { my $caller = caller 0; if (@_ > 1 and $_[1] ne '') { my @path = File::Spec->splitpath($_[1]); if ($path[0] . $path[1] eq '' and $path[2] ne '.' and $path[2] ne '..') { if (defined which $_[1]) { $elixir{$caller} = $_[1]; } else { $elixir{$caller} = File::Spec->join($_[1], $elixir); warn "No program like '$_[1]' or '$elixir{$caller}' can be executed" unless grep { -x $elixir{$caller} . $_ } '', split ';', $ENV{'PATHEXT'} || '.exe;.com;.bat'; } } else { $elixir{$caller} = -d $_[1] ? File::Spec->join($_[1], $elixir) : $_[1]; warn "No program like '$elixir{$caller}' can be executed" unless grep { -x $elixir{$caller} . $_ } '', split ';', $ENV{'PATHEXT'} || '.exe;.com;.bat'; } } else { delete $elixir{$caller}; warn "No program like '$elixir' can be executed" unless defined which $elixir; } return exists $elixir{$caller} ? $elixir{$caller} : $elixir; } sub elixir { my $mode = defined $_[0] && ! ref $_[0] ? shift : ''; my $opts = defined $_[0] && ref $_[0] eq 'ARRAY' ? shift : []; my $text = join "", map { $_ =~ /\n$/ ? $_ : $_ . "\n" } @_; my $code = Encode::is_utf8($text); my $caller = caller 0; $caller = caller 1 if $caller eq __PACKAGE__; my $system = exists $elixir{$caller} ? $elixir{$caller} : $elixir; my $params = join " ", $mode, map { '"' . $_ . '"' } @{$opts}; my $handle = new File::Temp; local $\ = ""; print $handle $code ? encode "utf8", $text : $text; my $data = scalar `"$system" $params < "$handle"`; return $code ? decode "utf8", $data : $data; } sub main { return elixir @_; } sub resolve { return elixir 'resolve', @_; } sub inflect { return elixir 'inflect', @_; } sub derive { return elixir 'derive', @_; } sub lookup { return elixir 'lookup', @_; } 1; __END__ =head1 NAME Encode::Arabic::Exec - Interface to the Encode Arabic executables =head1 SYNOPSIS use Encode::Arabic::Exec; # 'encode' and 'decode' will be tried out use ElixirFM::Exec '.'; # './elixir' will be invoked use ElixirFM::Exec './elixir'; # './elixir' will be invoked use ElixirFM::Exec 'some/other'; # 'some/other/elixir' unless # 'some/other' is executable ElixirFM::Exec::elixir 'help'; import ElixirFM::Exec 'other/elixir'; # switching to 'other/elixir' ElixirFM::Exec::elixir 'inflect', # requested mode of operation ["V[PI]---3MS--"], # optional command-line params "(1320,1)", # supplied standard-input data "(1234,[])"; # which can be split by lines ElixirFM::Exec::inflect ["V[PI]---3MS--"], "(1320,1)", "(1234,[])"; =head1 DESCRIPTION The L module provides a simple interface for invoking the Encode Arabic executables, which you need to install on your system yourself. The download and further information are at L. =head1 AUTHOR Otakar Smrz C<< >>, L =head1 COPYRIGHT & LICENSE Copyright (C) 2005-2012 Otakar Smrz This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3. =cut Encode-Arabic-14.1/lib/Encode/Arabic/ArabTeX.pm000444001750001750 33735412410623243 21121 0ustar00otakarotakar000000000000# ##################################################################### Otakar Smrz, 2003/01/23 # # Encoding of Arabic: ArabTeX Notation by Klaus Lagally ############################ 2003/06/19 package Encode::Arabic::ArabTeX; our $VERSION = '14.1'; use 5.008; use strict; use warnings; use Scalar::Util 'blessed'; use Carp; use Encode::Encoding; use base 'Encode::Encoding'; __PACKAGE__->Define('ArabTeX', 'Lagally', 'TeX'); use Encode::Mapper ':others', ':silent', ':join'; our %options; # records of options per package .. global register our %option; # options of the caller package .. used with local our $enmode; our $demode; our $enlevel = 2; our $delevel = 3; our %modemap = ( 'default' => 3, 'undef' => 0, 'fullvocalize' => 4, 'full' => 4, 'vocalize' => 3, 'nosukuun' => 3, 'novocalize' => 2, 'novowels' => 2, 'none' => 2, 'noshadda' => 1, 'noneplus' => 1, ); sub import { # perform import as if Encode were used one level before this module if (defined $_[1] and $_[1] eq ':xml') { # interfere little with possible Encode's options Encode::Mapper->options ( 'override' => [ # override rules of these LHS .. 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 ] ); splice @_, 1, 1; } if (defined $_[1] and $_[1] eq ':simple') { __PACKAGE__->options($_[1]); splice @_, 1, 1; } if (defined $_[1] and $_[1] eq ':describe') { __PACKAGE__->options($_[1]); splice @_, 1, 1; } require Encode; push @Encode::ISA, 'Exporter' unless Encode->can('export_to_level'); Encode->export_to_level(1, @_); } sub options ($%) { my $cls = shift @_; my ($i, $opt, %opt); my @returns = %option; while (@_) { $opt = lc shift @_; if ($opt =~ /^\:/) { $opt eq ':simple' and $opt{'non-quoting'} = 1 and $opt{'non-refined'} = 1 and next; $opt eq ':describe' and $opt{'describe'} = 1 and next; } else { $opt =~ /^\-*(.*)$/; $opt{$1} = shift @_; } } return %opt unless defined $cls; $option{$_} = $opt{$_} foreach keys %opt; return @returns; } sub encode ($$;$) { my ($cls, $text, $check) = @_; $cls = blessed $cls if ref $cls; no strict 'refs'; $cls->encoder() unless defined ${ $cls . '::encoder' }; return Encode::Mapper->encode($text, ${ $cls . '::encoder' }, undef); } sub decode ($$;$) { my ($cls, $text, $check) = @_; $cls = blessed $cls if ref $cls; no strict 'refs'; $cls->decoder() unless defined ${ $cls . '::decoder' }; return Encode::Mapper->decode($text, ${ $cls . '::decoder' }, 'utf8'); } sub encoder ($@) { my $cls = shift @_; my $encoder = $cls->eecoder('encoder', @_); return $encoder unless defined $encoder and $encoder == -1; $encoder = []; $encoder->[0] = Encode::Mapper->compile ( [ 'silent' => 0, ], ( map { chr 0x0660 + $_, "" . $_, } 0 .. 9 ), "\x{064B}", "aN", # 240 "\xF0", # "\xD9\x8B" "\x{064C}", "uN", # 241 "\xF1", # "\xD9\x8C" "\x{064D}", "iN", # 242 "\xF2", # "\xD9\x8D" "\x{064E}", "a", # 243 "\xF3", # "\xD9\x8E" "\x{064F}", "u", # 245 "\xF5", # "\xD9\x8F" "\x{0650}", "i", # 246 "\xF6", # "\xD9\x90" "\x{0670}", "_a", "\x{0657}", "_u", "\x{0656}", "_i", "\x{060C}", ",", # 161 "\xA1", # "\xD8\x8C" right-to-left-comma "\x{061B}", ";", # 186 "\xBA", # "\xD8\x9B" right-to-left-semicolon "\x{061F}", "?", # 191 "\xBF", # "\xD8\x9F" right-to-left-question-mark "\x{0621}", "'", # 193 "\xC1", # "\xD8\xA1" hamza-on-the-line "\x{0622}", "'A", # 194 "\xC2", # "\xD8\xA2" madda-over-'alif "\x{0623}", "'", # 195 "\xC3", # "\xD8\xA3" hamza-over-'alif "\x{0624}", "'", # 196 "\xC4", # "\xD8\xA4" hamza-over-waaw "\x{0625}", "'", # 197 "\xC5", # "\xD8\xA5" hamza-under-'alif "\x{0626}", "'", # 198 "\xC6", # "\xD8\xA6" hamza-over-yaa' "\x{0627}", "A", # 199 "\xC7", # "\xD8\xA7" bare 'alif "\x{0628}", "b", # 200 "\xC8", # "\xD8\xA8" "\x{0629}", "T", # 201 "\xC9", # "\xD8\xA9" "\x{062A}", "t", # 202 "\xCA", # "\xD8\xAA" "\x{062B}", "_t", # 203 "\xCB", # "\xD8\xAB" <_t> "\x{062C}", "^g", # 204 "\xCC", # "\xD8\xAC" <^g> "\x{062D}", ".h", # 205 "\xCD", # "\xD8\xAD" <.h> "\x{062E}", "_h", # 206 "\xCE", # "\xD8\xAE" <_h> "\x{062F}", "d", # 207 "\xCF", # "\xD8\xAF" "\x{0630}", "_d", # 208 "\xD0", # "\xD8\xB0" <_d> "\x{0631}", "r", # 209 "\xD1", # "\xD8\xB1" "\x{0632}", "z", # 210 "\xD2", # "\xD8\xB2" "\x{0633}", "s", # 211 "\xD3", # "\xD8\xB3" "\x{0634}", "^s", # 212 "\xD4", # "\xD8\xB4" <^s> "\x{0635}", ".s", # 213 "\xD5", # "\xD8\xB5" <.s> "\x{0636}", ".d", # 214 "\xD6", # "\xD8\xB6" <.d> "\x{0637}", ".t", # 216 "\xD8", # "\xD8\xB7" <.t> "\x{0638}", ".z", # 217 "\xD9", # "\xD8\xB8" <.z> "\x{0639}", "`", # 218 "\xDA", # "\xD8\xB9" <`> "\x{063A}", ".g", # 219 "\xDB", # "\xD8\xBA" <.g> "\x{0640}", "--", # 220 "\xDC", # "\xD9\x80" ta.twiil "\x{0641}", "f", # 221 "\xDD", # "\xD9\x81" "\x{0642}", "q", # 222 "\xDE", # "\xD9\x82" "\x{0643}", "k", # 223 "\xDF", # "\xD9\x83" "\x{0644}", "l", # 225 "\xE1", # "\xD9\x84" "\x{0645}", "m", # 227 "\xE3", # "\xD9\x85" "\x{0646}", "n", # 228 "\xE4", # "\xD9\x86" "\x{0647}", "h", # 229 "\xE5", # "\xD9\x87" "\x{0648}", "w", # 230 "\xE6", # "\xD9\x88" "\x{0649}", "Y", # 236 "\xEC", # "\xD9\x89" 'alif maq.suura "\x{064A}", "y", # 237 "\xED", # "\xD9\x8A" "\x{0651}", "\\shadda{}", # 248 "\xF8", # "\xD9\x91" ^sadda # "\x{0652}", '"', # 250 "\xFA", # "\xD9\x92" sukuun "\x{0652}", "", # 250 "\xFA", # "\xD9\x92" sukuun "\x{0671}", "A", # 199 "\xC7", # "\xD9\xB1" wa.sla-on-'alif "\x{067E}", "p", "\x{06A4}", "v", "\x{06AF}", "g", "\x{0681}", "c", "\x{0686}", "^c", "\x{0685}", ",c", "\x{0698}", "^z", "\x{06AD}", "^n", "\x{06B5}", "^l", "\x{0695}", ".r", "\x{0628}\x{0651}", "bb", # 200 "\xC8", # "\xD8\xA8" "\x{062A}\x{0651}", "tt", # 202 "\xCA", # "\xD8\xAA" "\x{062B}\x{0651}", "_t_t", # 203 "\xCB", # "\xD8\xAB" <_t> "\x{062C}\x{0651}", "^g^g", # 204 "\xCC", # "\xD8\xAC" <^g> "\x{062D}\x{0651}", ".h.h", # 205 "\xCD", # "\xD8\xAD" <.h> "\x{062E}\x{0651}", "_h_h", # 206 "\xCE", # "\xD8\xAE" <_h> "\x{062F}\x{0651}", "dd", # 207 "\xCF", # "\xD8\xAF" "\x{0630}\x{0651}", "_d_d", # 208 "\xD0", # "\xD8\xB0" <_d> "\x{0631}\x{0651}", "rr", # 209 "\xD1", # "\xD8\xB1" "\x{0632}\x{0651}", "zz", # 210 "\xD2", # "\xD8\xB2" "\x{0633}\x{0651}", "ss", # 211 "\xD3", # "\xD8\xB3" "\x{0634}\x{0651}", "^s^s", # 212 "\xD4", # "\xD8\xB4" <^s> "\x{0635}\x{0651}", ".s.s", # 213 "\xD5", # "\xD8\xB5" <.s> "\x{0636}\x{0651}", ".d.d", # 214 "\xD6", # "\xD8\xB6" <.d> "\x{0637}\x{0651}", ".t.t", # 216 "\xD8", # "\xD8\xB7" <.t> "\x{0638}\x{0651}", ".z.z", # 217 "\xD9", # "\xD8\xB8" <.z> "\x{0639}\x{0651}", "``", # 218 "\xDA", # "\xD8\xB9" <`> "\x{063A}\x{0651}", ".g.g", # 219 "\xDB", # "\xD8\xBA" <.g> "\x{0641}\x{0651}", "ff", # 221 "\xDD", # "\xD9\x81" "\x{0642}\x{0651}", "qq", # 222 "\xDE", # "\xD9\x82" "\x{0643}\x{0651}", "kk", # 223 "\xDF", # "\xD9\x83" "\x{0644}\x{0651}", "ll", # 225 "\xE1", # "\xD9\x84" "\x{0645}\x{0651}", "mm", # 227 "\xE3", # "\xD9\x85" "\x{0646}\x{0651}", "nn", # 228 "\xE4", # "\xD9\x86" "\x{0647}\x{0651}", "hh", # 229 "\xE5", # "\xD9\x87" "\x{0648}\x{0651}", "ww", # 230 "\xE6", # "\xD9\x88" "\x{064A}\x{0651}", "yy", # 237 "\xED", # "\xD9\x8A" ); no strict 'refs'; ${ $cls . '::encoder' } = $encoder; if ($option{'describe'}) { $_->describe('') foreach @{${ $cls . '::encoder' }}; } $cls->enmode(defined ${ $cls . '::enmode' } ? ${ $cls . '::enmode' } : 'default'); return ${ $cls . '::encoder' }; } sub decoder ($@) { my $cls = shift @_; my $decoder = $cls->eecoder('decoder', @_); return $decoder unless defined $decoder and $decoder == -1; $decoder = []; my @sunny = ( [ "t", "\x{062A}" ], # "\xD8\xAA" [ "_t", "\x{062B}" ], # "\xD8\xAB" <_t> [ "d", "\x{062F}" ], # "\xD8\xAF" [ "_d", "\x{0630}" ], # "\xD8\xB0" <_d> [ "r", "\x{0631}" ], # "\xD8\xB1" [ "z", "\x{0632}" ], # "\xD8\xB2" [ "s", "\x{0633}" ], # "\xD8\xB3" [ "^s", "\x{0634}" ], # "\xD8\xB4" <^s> [ ".s", "\x{0635}" ], # "\xD8\xB5" <.s> [ ".d", "\x{0636}" ], # "\xD8\xB6" <.d> [ ".t", "\x{0637}" ], # "\xD8\xB7" <.t> [ ".z", "\x{0638}" ], # "\xD8\xB8" <.z> [ "l", "\x{0644}" ], # "\xD9\x84" [ "n", "\x{0646}" ], # "\xD9\x86" ); my @empty = ( [ "|", "" ], # ArabTeX's "invisible consonant" [ "", "\x{0627}" ], # "\xD8\xA7" bare 'alif ); my @taaaa = ( [ "T", "\x{0629}" ], # "\xD8\xA9" [ "H", "\x{0629}" ], # "\xD8\xA9" ); my @moony = ( [ "'A", "\x{0622}" ], # "\xD8\xA2" madda-over-'alif [ "'a", "\x{0623}" ], # "\xD8\xA3" hamza-over-'alif [ "'i", "\x{0625}" ], # "\xD8\xA5" hamza-under-'alif [ "'w", "\x{0624}" ], # "\xD8\xA4" hamza-over-waaw [ "'y", "\x{0626}" ], # "\xD8\xA6" hamza-over-yaa' [ "'|", "\x{0621}" ], # "\xD8\xA1" hamza-on-the-line [ "b", "\x{0628}" ], # "\xD8\xA8" [ "^g", "\x{062C}" ], # "\xD8\xAC" <^g> [ ".h", "\x{062D}" ], # "\xD8\xAD" <.h> [ "_h", "\x{062E}" ], # "\xD8\xAE" <_h> [ "`", "\x{0639}" ], # "\xD8\xB9" <`> [ ".g", "\x{063A}" ], # "\xD8\xBA" <.g> [ "f", "\x{0641}" ], # "\xD9\x81" [ "q", "\x{0642}" ], # "\xD9\x82" [ "k", "\x{0643}" ], # "\xD9\x83" [ "m", "\x{0645}" ], # "\xD9\x85" [ "h", "\x{0647}" ], # "\xD9\x87" [ "w", "\x{0648}" ], # "\xD9\x88" [ "y", "\x{064A}" ], # "\xD9\x8A" [ "B", "\x{0640}" ], # ArabTeX's "consonantal ta.twiil" [ "p", "\x{067E}" ], [ "v", "\x{06A4}" ], [ "g", "\x{06AF}" ], [ "c", "\x{0681}" ], # .ha with hamza [ "^c", "\x{0686}" ], # gim with three [ ",c", "\x{0685}" ], # _ha with three [ "^z", "\x{0698}" ], # zay with three [ "^n", "\x{06AD}" ], # kaf with three [ "^l", "\x{06B5}" ], # lam with a bow above [ ".r", "\x{0695}" ], # ra' with a bow below ); my @scope = ( "b", "t", "_t", "^g", ".h", "_h", "d", "_d", "r", "z", "s", "^s", ".s", ".d", ".t", ".z", "`", ".g", "f", "q", "k", "l", "m", "n", "h", "w", "p", "v", "g", "c", "^c", ",c", "^z", "^n", "^l", ".r", "|", "B", # "'", "y" treated specifically in some cases -- "T", "H" must as well ); $decoder->[0] = Encode::Mapper->compile ( [ 'silent' => 0, ], "_A", [ "", "Y" ], "_U", [ "", "U" ], "WA", [ "", "W" ], "y_A", [ "", "yY" ], "yaN_A", [ "", "yaNY" ], "yaNY", [ "", "yaN" ], "yY", [ "y", "A" ], # word-internal occurrence "TA", [ "t", "A" ], "TU", [ "t", "U" ], "TI", [ "t", "I" ], "TY", [ "t", "Y" ], "T_I", [ "t", "_I" ], "T_A", [ "t", "_A" ], "T_U", [ "t", "_U" ], ( map { "T" . $_, [ "t", $_ ], "Ta" . $_, [ "t", "a" . $_ ], "Tu" . $_, [ "t", "u" . $_ ], "Ti" . $_, [ "t", "i" . $_ ], ( $option{'non-quoting'} ? () : ( "T\"" . $_, [ "t", "\"" . $_ ], "T\"a" . $_, [ "t", "\"a" . $_ ], "T\"u" . $_, [ "t", "\"u" . $_ ], "T\"i" . $_, [ "t", "\"i" . $_ ], ) ), } @scope, "y" # "T", "H", "W" ), "Ta'", [ "t", "a'" ], "Tu'", [ "t", "u'" ], "Ti'", [ "t", "i'" ], ( $option{'non-quoting'} ? () : ( "T\"'", [ "t", "\"'" ], "T\"a'", [ "t", "\"a'" ], "T\"u'", [ "t", "\"u'" ], "T\"i'", [ "t", "\"i'" ], ) ), ( map { "Y" . $_, [ "A", $_ ], } @scope, "y", "T", "H" # "W" ), # vowel-quoted sequences ( $option{'non-quoting'} ? ( "\"", "", # use non-quoting quotes only on no purpose ^^ ) : ( "\"", "\"", ) ), # general non-protection of \TeX directives ( map { "\\cap" . $_, [ "\\", "cap" . $_ ], } 'A' .. 'Z', 'a' .. 'z', '_', '0' .. '9' ), "\\", "\\", # strict \cap removal and white-space collapsing ( map { "\\cap" . $_ . "\x09", [ "", "\\cap " ], "\\cap" . $_ . "\x0A", [ "", "\\cap " ], "\\cap" . $_ . "\x0D", [ "", "\\cap " ], "\\cap" . $_ . "\x20", [ "", "\\cap " ], "\\cap" . $_, "", } "\x09", "\x0A", "\x0D", "\x20" ), "\\cap", "", # interfering rarely with the notation, or erroneous "^A'a", [ "^A'|", "a" ], "^A", [ "^A", "|" ], "^I", [ "^I", "|" ], "^U", [ "^U", "|" ], "_a", [ "_a", "|" ], "_i", [ "_i", "|" ], "_u", [ "_u", "|" ], "_aA", [ "_aA", "|" ], "_aY", [ "_aY", "|" ], "_aU", [ "_aU", "|" ], "_aI", [ "_aI", "|" ], "'_a", [ "", "_a" ], "'_i", [ "", "_i" ], "'_u", [ "", "_u" ], "'^A", [ "", "^A" ], "'^I", [ "", "^I" ], "'^U", [ "", "^U" ], # word-initial carriers "'", "'a", # covers much implicitly "'i", [ "'i", "i" ], "'A", [ "'", "A" ], "'I", [ "'i", "I" ], "'_I", [ "'i", "_I" ], "''", "'a'a", # .. still needed ^^ "''i", [ "'i'i", "i" ], "''I", [ "'i'i", "I" ], "''_I", [ "'i'i", "_I" ], ( $option{'non-quoting'} ? () : ( "'\"i", [ "'i\"", "i" ], "'\"A", [ "'", "A" ], "'\"I", [ "'i\"", "I" ], "'\"_I", [ "'i\"", "_I" ], "''\"i", [ "'i'i\"", "i" ], "''\"I", [ "'i'i\"", "I" ], "''\"_I", [ "'i'i\"", "_I" ], ) ), # word-final carriers "Y'", "A'|", "A'", "A'|", "I'", "I'|", "U'", "U'|", # "a'", "a'a", # "a'i", "a'ii", # "a'\"i", "a'i\"i", "i'", "i'y", "u'", "u'w", "Y''", "A'|'|", "A''", "A'|'|", "I''", "I'|'|", "U''", "U'|'|", # "a''", "a'a'a", # "a''i", "a'i'ii", # "a''\"i", "a'i'i\"i", "i''", "i'y'y", "u''", "u'w'w", ( map { # covers cases in the map below over @scope and # quoted included $_ . "'", $_ . "'|", $_ . "''", $_ . "'|'|", } @scope, "y", $option{'non-quoting'} ? () : "\"" # quoted included ), "T'", "t'|", "T''", "t'|'|", # word-internal carriers # doubled "a'A", [ "a'", "A" ], # unclear ^^ "a'I", [ "a'y", "I" ], "a''I", [ "a'y'y", "I" ], "a'U", [ "a'w", "U" ], "a''U", [ "a'w'w", "U" ], "a'_I", [ "a'y", "_I" ], "a''_I", [ "a'y'y", "_I" ], "u'I", [ "u'y", "I" ], "u''I", [ "u'y'y", "I" ], "u'_I", [ "u'y", "_I" ], "u''_I", [ "u'y'y", "_I" ], "I'aN", [ "I'y", "aN" ], "I''aN", [ "I'y'y", "aN" ], "y'aN", [ "y'y", "aN" ], "y''aN", [ "y'y'y", "aN" ], "A'A", [ "A'|", "A" ], "A''A", [ "A'|'|", "A" ], "A'I", [ "A'y", "I" ], "A''I", [ "A'y'y", "I" ], "A'U", [ "A'w", "U" ], "A''U", [ "A'w'w", "U" ], "A'Y", [ "A'|", "Y" ], "A''Y", [ "A'|'|", "Y" ], "A'_I", [ "A'y", "_I" ], "A''_I", [ "A'y'y", "_I" ], "A'_U", [ "", "A'U" ], "A''_U", [ "", "A''U" ], "A'_A", [ "", "A'Y" ], "A''_A", [ "", "A''Y" ], "I'A", [ "I'y", "A" ], "I''A", [ "I'y'y", "A" ], "I'I", [ "I'y", "I" ], "I''I", [ "I'y'y", "I" ], "I'U", [ "I'y", "U" ], "I''U", [ "I'y'y", "U" ], "I'Y", [ "I'y", "Y" ], "I''Y", [ "I'y'y", "Y" ], "I'_I", [ "I'y", "_I" ], "I''_I", [ "I'y'y", "_I" ], "I'_U", [ "", "I'U" ], "I''_U", [ "", "I''U" ], "I'_A", [ "", "I'Y" ], "I''_A", [ "", "I''Y" ], "y'A", [ "y'y", "A" ], "y''A", [ "y'y'y", "A" ], "y'I", [ "y'y", "I" ], "y''I", [ "y'y'y", "I" ], "y'U", [ "y'y", "U" ], "y''U", [ "y'y'y", "U" ], "y'Y", [ "y'y", "Y" ], "y''Y", [ "y'y'y", "Y" ], "y'_I", [ "y'y", "_I" ], "y''_I", [ "y'y'y", "_I" ], "y'_U", [ "", "y'U" ], "y''_U", [ "", "y''U" ], "y'_A", [ "", "y'Y" ], "y''_A", [ "", "y''Y" ], "U'A", [ "U'w", "A" ], "U''A", [ "U'w'w", "A" ], "U'I", [ "U'y", "I" ], "U''I", [ "U'y'y", "I" ], "U'U", [ "U'w", "U" ], "U''U", [ "U'w'w", "U" ], "U'Y", [ "U'w", "Y" ], "U''Y", [ "U'w'w", "Y" ], "U'_I", [ "U'y", "_I" ], "U''_I", [ "U'y'y", "_I" ], "U'_U", [ "", "U'U" ], "U''_U", [ "", "U''U" ], "U'_A", [ "", "U'Y" ], "U''_A", [ "", "U''Y" ], "uw'A", [ "uw'w", "A" ], "uw''A", [ "uw'w'w", "A" ], "uw'I", [ "uw'y", "I" ], "uw''I", [ "uw'y'y", "I" ], "uw'U", [ "uw'w", "U" ], "uw''U", [ "uw'w'w", "U" ], "uw'Y", [ "uw'w", "Y" ], "uw''Y", [ "uw'w'w", "Y" ], "uw'_I", [ "uw'y", "_I" ], "uw''_I", [ "uw'y'y", "_I" ], "uw'_U", [ "", "uw'U" ], "uw''_U", [ "", "uw''U" ], "uw'_A", [ "", "uw'Y" ], "uw''_A", [ "", "uw''Y" ], ( $option{'non-quoting'} ? () : ( "a'\"A", [ "a'", "A" ], # unclear ^^ "a'\"I", [ "a'y\"", "I" ], "a''\"I", [ "a'y'y\"", "I" ], "a'\"U", [ "a'w\"", "U" ], "a''\"U", [ "a'w'w\"", "U" ], "a'\"_I", [ "a'y\"", "_I" ], "a''\"_I", [ "a'y'y\"", "_I" ], "u'\"I", [ "u'y\"", "I" ], "u''\"I", [ "u'y'y\"", "I" ], "u'\"_I", [ "u'y\"", "_I" ], "u''\"_I", [ "u'y'y\"", "_I" ], "I'\"aN", [ "I'y\"", "aN" ], "I''\"aN", [ "I'y'y\"", "aN" ], "y'\"aN", [ "y'y\"", "aN" ], "y''\"aN", [ "y'y'y\"", "aN" ], "y\"'\"aN", [ "y\"'y\"", "aN" ], "y\"''\"aN", [ "y\"'y'y\"", "aN" ], "y\"'aN", [ "y\"'y", "aN" ], "y\"''aN", [ "y\"'y'y", "aN" ], "A'\"A", [ "A'|\"", "A" ], "A''\"A", [ "A'|'|\"", "A" ], "A'\"I", [ "A'y\"", "I" ], "A''\"I", [ "A'y'y\"", "I" ], "A'\"U", [ "A'w\"", "U" ], "A''\"U", [ "A'w'w\"", "U" ], "A'\"Y", [ "A'|\"", "Y" ], "A''\"Y", [ "A'|'|\"", "Y" ], "A'\"_I", [ "A'y\"", "_I" ], "A''\"_I", [ "A'y'y\"", "_I" ], "A'\"_U", [ "", "A'\"U" ], "A''\"_U", [ "", "A''\"U" ], "A'\"_A", [ "", "A'\"Y" ], "A''\"_A", [ "", "A''\"Y" ], "I'\"A", [ "I'y\"", "A" ], "I''\"A", [ "I'y'y\"", "A" ], "I'\"I", [ "I'y\"", "I" ], "I''\"I", [ "I'y'y\"", "I" ], "I'\"U", [ "I'y\"", "U" ], "I''\"U", [ "I'y'y\"", "U" ], "I'\"Y", [ "I'y\"", "Y" ], "I''\"Y", [ "I'y'y\"", "Y" ], "I'\"_I", [ "I'y\"", "_I" ], "I''\"_I", [ "I'y'y\"", "_I" ], "I'\"_U", [ "", "I'\"U" ], "I''\"_U", [ "", "I''\"U" ], "I'\"_A", [ "", "I'\"Y" ], "I''\"_A", [ "", "I''\"Y" ], "y'\"A", [ "y'y\"", "A" ], "y''\"A", [ "y'y'y\"", "A" ], "y'\"I", [ "y'y\"", "I" ], "y''\"I", [ "y'y'y\"", "I" ], "y'\"U", [ "y'y\"", "U" ], "y''\"U", [ "y'y'y\"", "U" ], "y'\"Y", [ "y'y\"", "Y" ], "y''\"Y", [ "y'y'y\"", "Y" ], "y'\"_I", [ "y'y\"", "_I" ], "y''\"_I", [ "y'y'y\"", "_I" ], "y'\"_U", [ "", "y'\"U" ], "y''\"_U", [ "", "y''\"U" ], "y'\"_A", [ "", "y'\"Y" ], "y''\"_A", [ "", "y''\"Y" ], "y\"'\"A", [ "y\"'y\"", "A" ], "y\"''\"A", [ "y\"'y'y\"", "A" ], "y\"'\"I", [ "y\"'y\"", "I" ], "y\"''\"I", [ "y\"'y'y\"", "I" ], "y\"'\"U", [ "y\"'y\"", "U" ], "y\"''\"U", [ "y\"'y'y\"", "U" ], "y\"'\"Y", [ "y\"'y\"", "Y" ], "y\"''\"Y", [ "y\"'y'y\"", "Y" ], "y\"'\"_I", [ "y\"'y\"", "_I" ], "y\"''\"_I", [ "y\"'y'y\"", "_I" ], "y\"'\"_U", [ "", "y\"'\"U" ], "y\"''\"_U", [ "", "y\"''\"U" ], "y\"'\"_A", [ "", "y\"'\"Y" ], "y\"''\"_A", [ "", "y\"''\"Y" ], "y\"'A", [ "y\"'y", "A" ], "y\"''A", [ "y\"'y'y", "A" ], "y\"'I", [ "y\"'y", "I" ], "y\"''I", [ "y\"'y'y", "I" ], "y\"'U", [ "y\"'y", "U" ], "y\"''U", [ "y\"'y'y", "U" ], "y\"'Y", [ "y\"'y", "Y" ], "y\"''Y", [ "y\"'y'y", "Y" ], "y\"'_I", [ "y\"'y", "_I" ], "y\"''_I", [ "y\"'y'y", "_I" ], "y\"'_U", [ "", "y\"'U" ], "y\"''_U", [ "", "y\"''U" ], "y\"'_A", [ "", "y\"'Y" ], "y\"''_A", [ "", "y\"''Y" ], "U'\"A", [ "U'w\"", "A" ], "U''\"A", [ "U'w'w\"", "A" ], "U'\"I", [ "U'y\"", "I" ], "U''\"I", [ "U'y'y\"", "I" ], "U'\"U", [ "U'w\"", "U" ], "U''\"U", [ "U'w'w\"", "U" ], "U'\"Y", [ "U'w\"", "Y" ], "U''\"Y", [ "U'w'w\"", "Y" ], "U'\"_I", [ "U'y\"", "_I" ], "U''\"_I", [ "U'y'y\"", "_I" ], "U'\"_U", [ "", "U'\"U" ], "U''\"_U", [ "", "U''\"U" ], "U'\"_A", [ "", "U'\"Y" ], "U''\"_A", [ "", "U''\"Y" ], "uw'\"A", [ "uw'w\"", "A" ], "uw''\"A", [ "uw'w'w\"", "A" ], "uw'\"I", [ "uw'y\"", "I" ], "uw''\"I", [ "uw'y'y\"", "I" ], "uw'\"U", [ "uw'w\"", "U" ], "uw''\"U", [ "uw'w'w\"", "U" ], "uw'\"Y", [ "uw'w\"", "Y" ], "uw''\"Y", [ "uw'w'w\"", "Y" ], "uw'\"_I", [ "uw'y\"", "_I" ], "uw''\"_I", [ "uw'y'y\"", "_I" ], "uw'\"_U", [ "", "uw'\"U" ], "uw''\"_U", [ "", "uw''\"U" ], "uw'\"_A", [ "", "uw'\"Y" ], "uw''\"_A", [ "", "uw''\"Y" ], ) ), ( map { # doubled "a'i" . $_, [ "a'y", "i" . $_ ], "a''i" . $_, [ "a'y'y", "i" . $_ ], "a'u" . $_, [ "a'w", "u" . $_ ], "a''u" . $_, [ "a'w'w", "u" . $_ ], "u'i" . $_, [ "u'y", "i" . $_ ], "u''i" . $_, [ "u'y'y", "i" . $_ ], "A'a" . $_, [ "A'|", "a" . $_ ], "A''a" . $_, [ "A'|'|", "a" . $_ ], "A'i" . $_, [ "A'y", "i" . $_ ], "A''i" . $_, [ "A'y'y", "i" . $_ ], "A'u" . $_, [ "A'w", "u" . $_ ], "A''u" . $_, [ "A'w'w", "u" . $_ ], "I'a" . $_, [ "I'y", "a" . $_ ], "I''a" . $_, [ "I'y'y", "a" . $_ ], "I'i" . $_, [ "I'y", "i" . $_ ], "I''i" . $_, [ "I'y'y", "i" . $_ ], "I'u" . $_, [ "I'y", "u" . $_ ], "I''u" . $_, [ "I'y'y", "u" . $_ ], "y'a" . $_, [ "y'y", "a" . $_ ], "y''a" . $_, [ "y'y'y", "a" . $_ ], "y'i" . $_, [ "y'y", "i" . $_ ], "y''i" . $_, [ "y'y'y", "i" . $_ ], "y'u" . $_, [ "y'y", "u" . $_ ], "y''u" . $_, [ "y'y'y", "u" . $_ ], "U'a" . $_, [ "U'w", "a" . $_ ], "U''a" . $_, [ "U'w'w", "a" . $_ ], "U'i" . $_, [ "U'y", "i" . $_ ], "U''i" . $_, [ "U'y'y", "i" . $_ ], "U'u" . $_, [ "U'w", "u" . $_ ], "U''u" . $_, [ "U'w'w", "u" . $_ ], "uw'a" . $_, [ "uw'w", "a" . $_ ], "uw''a" . $_, [ "uw'w'w", "a" . $_ ], "uw'i" . $_, [ "uw'y", "i" . $_ ], "uw''i" . $_, [ "uw'y'y", "i" . $_ ], "uw'u" . $_, [ "uw'w", "u" . $_ ], "uw''u" . $_, [ "uw'w'w", "u" . $_ ], ( $option{'non-quoting'} ? () : ( "a'\"i" . $_, [ "a'y\"", "i" . $_ ], "a''\"i" . $_, [ "a'y'y\"", "i" . $_ ], "a'\"u" . $_, [ "a'w\"", "u" . $_ ], "a''\"u" . $_, [ "a'w'w\"", "u" . $_ ], "u'\"i" . $_, [ "u'y\"", "i" . $_ ], "u''\"i" . $_, [ "u'y'y\"", "i" . $_ ], "A'\"a" . $_, [ "A'|\"", "a" . $_ ], "A''\"a" . $_, [ "A'|'|\"", "a" . $_ ], "A'\"i" . $_, [ "A'y\"", "i" . $_ ], "A''\"i" . $_, [ "A'y'y\"", "i" . $_ ], "A'\"u" . $_, [ "A'w\"", "u" . $_ ], "A''\"u" . $_, [ "A'w'w\"", "u" . $_ ], "I'\"a" . $_, [ "I'y\"", "a" . $_ ], "I''\"a" . $_, [ "I'y'y\"", "a" . $_ ], "I'\"i" . $_, [ "I'y\"", "i" . $_ ], "I''\"i" . $_, [ "I'y'y\"", "i" . $_ ], "I'\"u" . $_, [ "I'y\"", "u" . $_ ], "I''\"u" . $_, [ "I'y'y\"", "u" . $_ ], "y'\"a" . $_, [ "y'y\"", "a" . $_ ], "y''\"a" . $_, [ "y'y'y\"", "a" . $_ ], "y'\"i" . $_, [ "y'y\"", "i" . $_ ], "y''\"i" . $_, [ "y'y'y\"", "i" . $_ ], "y'\"u" . $_, [ "y'y\"", "u" . $_ ], "y''\"u" . $_, [ "y'y'y\"", "u" . $_ ], "y\"'\"a" . $_, [ "y\"'y\"", "a" . $_ ], "y\"''\"a" . $_, [ "y\"'y'y\"", "a" . $_ ], "y\"'\"i" . $_, [ "y\"'y\"", "i" . $_ ], "y\"''\"i" . $_, [ "y\"'y'y\"", "i" . $_ ], "y\"'\"u" . $_, [ "y\"'y\"", "u" . $_ ], "y\"''\"u" . $_, [ "y\"'y'y\"", "u" . $_ ], "y\"'a" . $_, [ "y\"'y", "a" . $_ ], "y\"''a" . $_, [ "y\"'y'y", "a" . $_ ], "y\"'i" . $_, [ "y\"'y", "i" . $_ ], "y\"''i" . $_, [ "y\"'y'y", "i" . $_ ], "y\"'u" . $_, [ "y\"'y", "u" . $_ ], "y\"''u" . $_, [ "y\"'y'y", "u" . $_ ], "U'\"a" . $_, [ "U'w\"", "a" . $_ ], "U''\"a" . $_, [ "U'w'w\"", "a" . $_ ], "U'\"i" . $_, [ "U'y\"", "i" . $_ ], "U''\"i" . $_, [ "U'y'y\"", "i" . $_ ], "U'\"u" . $_, [ "U'w\"", "u" . $_ ], "U''\"u" . $_, [ "U'w'w\"", "u" . $_ ], "uw'\"a" . $_, [ "uw'w\"", "a" . $_ ], "uw''\"a" . $_, [ "uw'w'w\"", "a" . $_ ], "uw'\"i" . $_, [ "uw'y\"", "i" . $_ ], "uw''\"i" . $_, [ "uw'y'y\"", "i" . $_ ], "uw'\"u" . $_, [ "uw'w\"", "u" . $_ ], "uw''\"u" . $_, [ "uw'w'w\"", "u" . $_ ], ) ), } "'", @scope, "y", "T", "H", "W", "_W" ), ( map { # doubled my $fix = $_; $_ . "'A", [ $_ . "'", "A" ], $_ . "''A", [ $_ . "'a'a", "A" ], $_ . "'I", [ $_ . "'y", "I" ], $_ . "''I", [ $_ . "'y'y", "I" ], $_ . "'U", [ $_ . "'w", "U" ], $_ . "''U", [ $_ . "'w'w", "U" ], $_ . "'Y", [ $_ . "'a", "Y" ], $_ . "''Y", [ $_ . "'a'a", "Y" ], $_ . "'aNY", [ $_ . "'a", "aNY" ], $_ . "''aNY", [ $_ . "'a'a", "aNY" ], $_ . "'_I", [ $_ . "'y", "_I" ], $_ . "''_I", [ $_ . "'y'y", "_I" ], $_ . "'_U", [ "", $_ . "'U" ], $_ . "''_U", [ "", $_ . "''U" ], ( $option{'non-quoting'} ? () : ( $_ . "'\"A", [ $_ . "'", "A" ], $_ . "''\"A", [ $_ . "'a'a\"", "A" ], $_ . "'\"I", [ $_ . "'y\"", "I" ], $_ . "''\"I", [ $_ . "'y'y\"", "I" ], $_ . "'\"U", [ $_ . "'w\"", "U" ], $_ . "''\"U", [ $_ . "'w'w\"", "U" ], $_ . "'\"Y", [ $_ . "'a\"", "Y" ], $_ . "''\"Y", [ $_ . "'a'a\"", "Y" ], $_ . "'\"aNY", [ $_ . "'a\"", "aNY" ], $_ . "''\"aNY", [ $_ . "'a'a\"", "aNY" ], $_ . "'\"_I", [ $_ . "'y\"", "_I" ], $_ . "''\"_I", [ $_ . "'y'y\"", "_I" ], $_ . "'\"_U", [ "", $_ . "'\"U" ], $_ . "''\"_U", [ "", $_ . "''\"U" ], ) ), map { # doubled $fix . "'a" . $_, [ $fix . "'a", "a" . $_ ], $fix . "''a" . $_, [ $fix . "'a'a", "a" . $_ ], $fix . "'i" . $_, [ $fix . "'y", "i" . $_ ], $fix . "''i" . $_, [ $fix . "'y'y", "i" . $_ ], $fix . "'u" . $_, [ $fix . "'w", "u" . $_ ], $fix . "''u" . $_, [ $fix . "'w'w", "u" . $_ ], ( $option{'non-quoting'} ? () : ( $fix . "'\"a" . $_, [ $fix . "'a\"", "a" . $_ ], $fix . "''\"a" . $_, [ $fix . "'a'a\"", "a" . $_ ], $fix . "'\"i" . $_, [ $fix . "'y\"", "i" . $_ ], $fix . "''\"i" . $_, [ $fix . "'y'y\"", "i" . $_ ], $fix . "'\"u" . $_, [ $fix . "'w\"", "u" . $_ ], $fix . "''\"u" . $_, [ $fix . "'w'w\"", "u" . $_ ], ) ), } "'", @scope, "y", "T", "H", "W", "_W" } @scope, $option{'non-quoting'} ? () : "\"" # quoted included ), "T'A", [ "t'", "A" ], "T''A", [ "t'a'a", "A" ], "T'I", [ "t'y", "I" ], "T''I", [ "t'y'y", "I" ], "T'U", [ "t'w", "U" ], "T''U", [ "t'w'w", "U" ], "T'_I", [ "t'y", "_I" ], "T''_I", [ "t'y'y", "_I" ], "T'_U", [ "", "T'U" ], "T''_U", [ "", "T''U" ], ( $option{'non-quoting'} ? () : ( "T'\"A", [ "t'", "A" ], "T''\"A", [ "t'a'a\"", "A" ], "T'\"I", [ "t'y\"", "I" ], "T''\"I", [ "t'y'y\"", "I" ], "T'\"U", [ "t'w\"", "U" ], "T''\"U", [ "t'w'w\"", "U" ], "T'\"_I", [ "t'y\"", "_I" ], "T''\"_I", [ "t'y'y\"", "_I" ], "T'\"_U", [ "", "T'\"U" ], "T''\"_U", [ "", "T''\"U" ], ) ), ( map { # doubled "T'a" . $_, [ "t'a", "a" . $_ ], "T''a" . $_, [ "t'a'a", "a" . $_ ], "T'i" . $_, [ "t'y", "i" . $_ ], "T''i" . $_, [ "t'y'y", "i" . $_ ], "T'u" . $_, [ "t'w", "u" . $_ ], "T''u" . $_, [ "t'w'w", "u" . $_ ], ( $option{'non-quoting'} ? () : ( "T'\"a" . $_, [ "t'a\"", "a" . $_ ], "T''\"a" . $_, [ "t'a'a\"", "a" . $_ ], "T'\"i" . $_, [ "t'y\"", "i" . $_ ], "T''\"i" . $_, [ "t'y'y\"", "i" . $_ ], "T'\"u" . $_, [ "t'w\"", "u" . $_ ], "T''\"u" . $_, [ "t'w'w\"", "u" . $_ ], ) ), } "'", @scope, "y" # "T", "H", "W" ), ); $decoder->[1] = Encode::Mapper->compile ( [ 'others' => undef, 'silent' => 0, ], # non-exciting entities "\x09", "\x09", "\x0A", "\x0A", "\x0D", "\x0D", " ", " ", ".", ".", ":", ":", "!", "!", "/", "/", "\\", "\\", ",", "\x{060C}", # "\xD8\x8C" right-to-left-comma ";", "\x{061B}", # "\xD8\x9B" right-to-left-semicolon "?", "\x{061F}", # "\xD8\x9F" right-to-left-question-mark "--", "\x{0640}", # "\xD9\x80" ta.twiil ( map { "" . $_, chr 0x0660 + $_, } 0 .. 9 ), # improper auxiliary vowels -- the case of conditioned deletion "-a", "", "-u", "", "-i", "", ( map { "-a" . $_->[0], [ "", "a" . $_->[0] ], "-i" . $_->[0], [ "", "i" . $_->[0] ], "-u" . $_->[0], [ "", "u" . $_->[0] ], } @sunny, @moony, @taaaa, $empty[0] ), # non-voweled/sukuuned sunnies and moonies ( map { my $x = 1 + $_; my $y = "\x{0651}" x $_; # "\xD9\x91" ^sadda map { my $fix = $_; $_->[0] x $x, $_->[1] . $y . "\x{0652}", # "\xD9\x92" sukuun ( $option{'non-refined'} ? () : ( $_->[0] x $x . "-a", $_->[1] . $y . "\x{064E}", $_->[0] x $x . "-u", $_->[1] . $y . "\x{064F}", $_->[0] x $x . "-i", $_->[1] . $y . "\x{0650}", $_->[0] x $x . "-A", $_->[1] . $y . "\x{064E}\x{0627}", $_->[0] x $x . "-Y", $_->[1] . $y . "\x{064E}\x{0649}", $_->[0] x $x . "-U", $_->[1] . $y . "\x{064F}\x{0648}", $_->[0] x $x . "-I", $_->[1] . $y . "\x{0650}\x{064A}", $_->[0] x $x . "-aN", $_->[1] . $y . "\x{064B}" . ( $_->[0] eq "'a" ? "" : "\x{0627}" ), $_->[0] x $x . "-uN", $_->[1] . $y . "\x{064C}", $_->[0] x $x . "-iN", $_->[1] . $y . "\x{064D}", $_->[0] x $x . "-aNA", $_->[1] . $y . "\x{064B}\x{0627}", $_->[0] x $x . "-uNA", $_->[1] . $y . "\x{064C}\x{0627}", $_->[0] x $x . "-iNA", $_->[1] . $y . "\x{064D}\x{0627}", $_->[0] x $x . "-aNY", $_->[1] . $y . "\x{064B}\x{0649}", $_->[0] x $x . "-uNY", $_->[1] . $y . "\x{064C}\x{0649}", $_->[0] x $x . "-iNY", $_->[1] . $y . "\x{064D}\x{0649}", $_->[0] x $x . "-aNU", $_->[1] . $y . "\x{064B}\x{0648}", $_->[0] x $x . "-uNU", $_->[1] . $y . "\x{064C}\x{0648}", $_->[0] x $x . "-iNU", $_->[1] . $y . "\x{064D}\x{0648}", ) ), ( $option{'non-quoting'} ? () : ( $_->[0] x $x . "\"", $_->[1] . $y . "\"\x{0652}", # "\xD9\x92" sukuun ( $option{'non-refined'} ? () : ( $_->[0] x $x . "-\"a", $_->[1] . $y . "\"\x{064E}", $_->[0] x $x . "-\"u", $_->[1] . $y . "\"\x{064F}", $_->[0] x $x . "-\"i", $_->[1] . $y . "\"\x{0650}", $_->[0] x $x . "-\"A", $_->[1] . $y . "\"\x{064E}\x{0627}", $_->[0] x $x . "-\"Y", $_->[1] . $y . "\"\x{064E}\x{0649}", $_->[0] x $x . "-\"U", $_->[1] . $y . "\"\x{064F}\x{0648}", $_->[0] x $x . "-\"I", $_->[1] . $y . "\"\x{0650}\x{064A}", $_->[0] x $x . "-\"aN", $_->[1] . $y . "\"\x{064B}" . ( $_->[0] eq "'a" ? "" : "\x{0627}" ), $_->[0] x $x . "-\"uN", $_->[1] . $y . "\"\x{064C}", $_->[0] x $x . "-\"iN", $_->[1] . $y . "\"\x{064D}", $_->[0] x $x . "-\"aNA", $_->[1] . $y . "\"\x{064B}\x{0627}", $_->[0] x $x . "-\"uNA", $_->[1] . $y . "\"\x{064C}\x{0627}", $_->[0] x $x . "-\"iNA", $_->[1] . $y . "\"\x{064D}\x{0627}", $_->[0] x $x . "-\"aNY", $_->[1] . $y . "\"\x{064B}\x{0649}", $_->[0] x $x . "-\"uNY", $_->[1] . $y . "\"\x{064C}\x{0649}", $_->[0] x $x . "-\"iNY", $_->[1] . $y . "\"\x{064D}\x{0649}", $_->[0] x $x . "-\"aNU", $_->[1] . $y . "\"\x{064B}\x{0648}", $_->[0] x $x . "-\"uNU", $_->[1] . $y . "\"\x{064C}\x{0648}", $_->[0] x $x . "-\"iNU", $_->[1] . $y . "\"\x{064D}\x{0648}", ) ), ) ), map { ( $option{'non-refined'} ? () : ( $fix->[0] x $x . "-a" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "a" . $_->[0] ], $fix->[0] x $x . "-u" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "u" . $_->[0] ], $fix->[0] x $x . "-i" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "i" . $_->[0] ], $fix->[0] x $x . "-A" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "A" . $_->[0] ], $fix->[0] x $x . "-Y" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "Y" . $_->[0] ], $fix->[0] x $x . "-U" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "U" . $_->[0] ], $fix->[0] x $x . "-I" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "I" . $_->[0] ], ( $option{'non-quoting'} ? () : ( $fix->[0] x $x . "-\"a" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "a" . $_->[0] ], $fix->[0] x $x . "-\"u" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "u" . $_->[0] ], $fix->[0] x $x . "-\"i" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "i" . $_->[0] ], $fix->[0] x $x . "-\"A" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "A" . $_->[0] ], $fix->[0] x $x . "-\"Y" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "Y" . $_->[0] ], $fix->[0] x $x . "-\"U" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "U" . $_->[0] ], $fix->[0] x $x . "-\"I" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "I" . $_->[0] ], ) ), ) ), } @sunny, @moony, @taaaa, $empty[0] } @sunny, @moony[1 .. $#moony], $empty[0] # $moony[0] excluded as long as is unclear ^^ } 0, 1 ), $moony[0]->[0], $moony[0]->[1], # now necessary of course ^^ # voweled/non-sukuuned sunnies and moonies ( map { my $x = 1 + $_; my $y = "\x{0651}" x $_; # "\xD9\x91" ^sadda map { my $fix = $_; $_->[0] x $x . "a", $_->[1] . $y . "\x{064E}", $_->[0] x $x . "u", $_->[1] . $y . "\x{064F}", $_->[0] x $x . "i", $_->[1] . $y . "\x{0650}", $_->[0] x $x . "_a", $_->[1] . $y . "\x{0670}", ( $option{'non-refined'} ? () : ( $_->[0] x $x . "_u", $_->[1] . $y . "\x{0657}", $_->[0] x $x . "_i", $_->[1] . $y . "\x{0656}", $_->[0] x $x . "_aA", $_->[1] . $y . "\x{0670}\x{0627}", $_->[0] x $x . "_aY", $_->[1] . $y . "\x{0670}\x{0649}", $_->[0] x $x . "_aU", $_->[1] . $y . "\x{0670}\x{0648}", $_->[0] x $x . "_aI", $_->[1] . $y . "\x{0670}\x{064A}", ) ), $_->[0] x $x . "A", $_->[1] . $y . "\x{064E}\x{0627}", $_->[0] x $x . "Y", $_->[1] . $y . "\x{064E}\x{0649}", $_->[0] x $x . "_I", $_->[1] . $y . "\x{0650}\x{0627}", $_->[0] x $x . "U", $_->[1] . $y . "\x{064F}\x{0648}", $_->[0] x $x . "I", $_->[1] . $y . "\x{0650}\x{064A}", $_->[0] x $x . "Uw", [ $_->[1] . $y . "\x{064F}", "ww" ], $_->[0] x $x . "Iy", [ $_->[1] . $y . "\x{0650}", "yy" ], ( $option{'non-refined'} ? () : ( $_->[0] x $x . "^A", $_->[1] . $y . "\x{064F}\x{0627}\x{0653}", $_->[0] x $x . "^U", $_->[1] . $y . "\x{064F}\x{0648}\x{0653}", $_->[0] x $x . "^I", $_->[1] . $y . "\x{0650}\x{064A}\x{0653}", $_->[0] x $x . "^Uw", [ $_->[1] . $y . "\x{064F}\x{0648}\x{0655}", "|" ], # roughly $_->[0] x $x . "^Iy", [ $_->[1] . $y . "\x{0650}\x{0649}\x{0655}", "|" ], # roughly ) ), $_->[0] x $x . "aa", [ "", $_->[0] x $x . "A" ], $_->[0] x $x . "uw", [ "", $_->[0] x $x . "U" ], $_->[0] x $x . "iy", [ "", $_->[0] x $x . "I" ], ( $option{'non-quoting'} ? () : ( $_->[0] x $x . "\"a", $_->[1] . $y . "\"\x{064E}", $_->[0] x $x . "\"u", $_->[1] . $y . "\"\x{064F}", $_->[0] x $x . "\"i", $_->[1] . $y . "\"\x{0650}", $_->[0] x $x . "\"_a", $_->[1] . $y . "\"\x{0670}", ( $option{'non-refined'} ? () : ( $_->[0] x $x . "\"_u", $_->[1] . $y . "\"\x{0657}", $_->[0] x $x . "\"_i", $_->[1] . $y . "\"\x{0656}", $_->[0] x $x . "\"_aA", $_->[1] . $y . "\"\x{0670}\x{0627}", $_->[0] x $x . "\"_aY", $_->[1] . $y . "\"\x{0670}\x{0649}", $_->[0] x $x . "\"_aU", $_->[1] . $y . "\"\x{0670}\x{0648}", $_->[0] x $x . "\"_aI", $_->[1] . $y . "\"\x{0670}\x{064A}", ) ), $_->[0] x $x . "\"A", $_->[1] . $y . "\"\x{064E}\x{0627}", $_->[0] x $x . "\"Y", $_->[1] . $y . "\"\x{064E}\x{0649}", $_->[0] x $x . "\"A\"", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}", $_->[0] x $x . "\"Y\"", $_->[1] . $y . "\"\x{064E}\x{0649}\"\x{0652}", $_->[0] x $x . "A\"", $_->[1] . $y . "\x{064E}\x{0627}\"\x{0652}", $_->[0] x $x . "Y\"", $_->[1] . $y . "\x{064E}\x{0649}\"\x{0652}", $_->[0] x $x . "\"_I", $_->[1] . $y . "\"\x{0650}\x{0627}", $_->[0] x $x . "\"_I\"", $_->[1] . $y . "\"\x{0650}\x{0627}\"\x{0652}", $_->[0] x $x . "_I\"", $_->[1] . $y . "\x{0650}\x{0627}\"\x{0652}", $_->[0] x $x . "\"U", $_->[1] . $y . "\"\x{064F}\x{0648}", $_->[0] x $x . "\"I", $_->[1] . $y . "\"\x{0650}\x{064A}", $_->[0] x $x . "\"U\"", $_->[1] . $y . "\"\x{064F}\x{0648}\"\x{0652}", $_->[0] x $x . "\"I\"", $_->[1] . $y . "\"\x{0650}\x{064A}\"\x{0652}", $_->[0] x $x . "U\"", $_->[1] . $y . "\x{064F}\x{0648}\"\x{0652}", $_->[0] x $x . "I\"", $_->[1] . $y . "\x{0650}\x{064A}\"\x{0652}", $_->[0] x $x . "\"Uw", [ $_->[1] . $y . "\"\x{064F}", "ww" ], $_->[0] x $x . "\"Iy", [ $_->[1] . $y . "\"\x{0650}", "yy" ], ( $option{'non-refined'} ? () : ( $_->[0] x $x . "\"^A", $_->[1] . $y . "\"\x{064F}\x{0627}\x{0653}", $_->[0] x $x . "\"^U", $_->[1] . $y . "\"\x{064F}\x{0648}\x{0653}", $_->[0] x $x . "\"^I", $_->[1] . $y . "\"\x{0650}\x{064A}\x{0653}", $_->[0] x $x . "\"^Uw", [ $_->[1] . $y . "\"\x{064F}\x{0648}\x{0655}", "|" ], # roughly $_->[0] x $x . "\"^Iy", [ $_->[1] . $y . "\"\x{0650}\x{0649}\x{0655}", "|" ], # roughly ) ), $_->[0] x $x . "\"aa", [ "", $_->[0] x $x . "\"A" ], $_->[0] x $x . "\"uw", [ "", $_->[0] x $x . "\"U" ], $_->[0] x $x . "\"iy", [ "", $_->[0] x $x . "\"I" ], ) ), ( map { $fix->[0] x $x . "uw" . $_, [ $fix->[1] . $y . "\x{064F}", "w" . $_ ], $fix->[0] x $x . "iy" . $_, [ $fix->[1] . $y . "\x{0650}", "y" . $_ ], ( $option{'non-quoting'} ? () : ( $fix->[0] x $x . "\"uw" . $_, [ $fix->[1] . $y . "\"\x{064F}", "w" . $_ ], $fix->[0] x $x . "\"iy" . $_, [ $fix->[1] . $y . "\"\x{0650}", "y" . $_ ], ) ), } "\"", qw "a u i A Y U I _I", $option{'non-refined'} ? () : qw "_a _u _i ^A ^U ^I" ), $_->[0] x $x . "_aA'|aN", $_->[1] . $y . "\x{0670}\x{0627}\x{0621}\x{064B}", $_->[0] x $x . "A'|aN", $_->[1] . $y . "\x{064E}\x{0627}\x{0621}\x{064B}", $_->[0] x $x . "aN", $_->[1] . $y . "\x{064B}" . ( $_->[0] eq "'a" ? "" : "\x{0627}" ), $_->[0] x $x . "uN", $_->[1] . $y . "\x{064C}", $_->[0] x $x . "iN", $_->[1] . $y . "\x{064D}", ( $option{'non-quoting'} ? () : ( $_->[0] x $x . "\"_aA'|aN", $_->[1] . $y . "\"\x{0670}\x{0627}\x{0621}\x{064B}", $_->[0] x $x . "\"A'|aN", $_->[1] . $y . "\"\x{064E}\x{0627}\x{0621}\x{064B}", $_->[0] x $x . "\"_aA'|\"aN", $_->[1] . $y . "\"\x{0670}\x{0627}\x{0621}\"\x{064B}", $_->[0] x $x . "\"A'|\"aN", $_->[1] . $y . "\"\x{064E}\x{0627}\x{0621}\"\x{064B}", $_->[0] x $x . "_aA'|\"aN", $_->[1] . $y . "\x{0670}\x{0627}\x{0621}\"\x{064B}", $_->[0] x $x . "A'|\"aN", $_->[1] . $y . "\x{064E}\x{0627}\x{0621}\"\x{064B}", $_->[0] x $x . "\"A\"'|aN", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\x{064B}", $_->[0] x $x . "\"A\"'|\"aN", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}", $_->[0] x $x . "A\"'|\"aN", $_->[1] . $y . "\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}", $_->[0] x $x . "\"aN", $_->[1] . $y . "\"\x{064B}" . ( $_->[0] eq "'a" ? "" : "\x{0627}" ), $_->[0] x $x . "\"uN", $_->[1] . $y . "\"\x{064C}", $_->[0] x $x . "\"iN", $_->[1] . $y . "\"\x{064D}", ) ), } @sunny, @moony, $empty[0] } 0, 1 ), # 'alif protected endings ( map { my $x = 1 + $_; my $y = "\x{0651}" x $_; # "\xD9\x91" ^sadda map { $_->[0] x $x . "_aA'|aNA", $_->[1] . $y . "\x{0670}\x{0627}\x{0621}\x{064B}\x{0627}", $_->[0] x $x . "A'|aNA", $_->[1] . $y . "\x{064E}\x{0627}\x{0621}\x{064B}\x{0627}", $_->[0] x $x . "aNA", $_->[1] . $y . "\x{064B}\x{0627}", $_->[0] x $x . "aNY", $_->[1] . $y . "\x{064B}\x{0649}", $_->[0] x $x . "uNU", $_->[1] . $y . "\x{064C}\x{0648}", $_->[0] x $x . "iNU", $_->[1] . $y . "\x{064D}\x{0648}", ( $option{'non-refined'} ? () : ( $_->[0] x $x . "uNA", $_->[1] . $y . "\x{064C}\x{0627}", $_->[0] x $x . "iNA", $_->[1] . $y . "\x{064D}\x{0627}", $_->[0] x $x . "uNY", $_->[1] . $y . "\x{064C}\x{0649}", $_->[0] x $x . "iNY", $_->[1] . $y . "\x{064D}\x{0649}", $_->[0] x $x . "aNU", $_->[1] . $y . "\x{064B}\x{0648}", $_->[0] x $x . "aW-a", $_->[1] . $y . "\x{064E}\x{0648}\x{064E}\x{0627}", $_->[0] x $x . "aW-u", $_->[1] . $y . "\x{064E}\x{0648}\x{064F}\x{0627}", $_->[0] x $x . "aW-i", $_->[1] . $y . "\x{064E}\x{0648}\x{0650}\x{0627}", ) ), $_->[0] x $x . "a_W", $_->[1] . $y . "\x{064E}\x{0648}", $_->[0] x $x . "u_W", $_->[1] . $y . "\x{064F}\x{0648}", $_->[0] x $x . "i_W", $_->[1] . $y . "\x{0650}\x{0648}", $_->[0] x $x . "aW", $_->[1] . $y . "\x{064E}\x{0648}\x{0652}\x{0627}", $_->[0] x $x . "uW", $_->[1] . $y . "\x{064F}\x{0648}\x{0627}", $_->[0] x $x . "UW", $_->[1] . $y . "\x{064F}\x{0648}\x{0627}", $_->[0] x $x . "UA", $_->[1] . $y . "\x{064F}\x{0648}\x{0627}", ( $option{'non-quoting'} ? () : ( $_->[0] x $x . "\"_aA'|aNA", $_->[1] . $y . "\"\x{0670}\x{0627}\x{0621}\x{064B}\x{0627}", $_->[0] x $x . "\"A'|aNA", $_->[1] . $y . "\"\x{064E}\x{0627}\x{0621}\x{064B}\x{0627}", $_->[0] x $x . "\"_aA'|\"aNA", $_->[1] . $y . "\"\x{0670}\x{0627}\x{0621}\"\x{064B}\x{0627}", $_->[0] x $x . "\"A'|\"aNA", $_->[1] . $y . "\"\x{064E}\x{0627}\x{0621}\"\x{064B}\x{0627}", $_->[0] x $x . "_aA'|\"aNA", $_->[1] . $y . "\x{0670}\x{0627}\x{0621}\"\x{064B}\x{0627}", $_->[0] x $x . "A'|\"aNA", $_->[1] . $y . "\x{064E}\x{0627}\x{0621}\"\x{064B}\x{0627}", $_->[0] x $x . "\"A\"'|aNA", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\x{064B}\x{0627}", $_->[0] x $x . "\"A\"'|\"aNA", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}\x{0627}", $_->[0] x $x . "A\"'|\"aNA", $_->[1] . $y . "\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}\x{0627}", $_->[0] x $x . "\"aNA", $_->[1] . $y . "\"\x{064B}\x{0627}", $_->[0] x $x . "\"aNY", $_->[1] . $y . "\"\x{064B}\x{0649}", $_->[0] x $x . "\"uNU", $_->[1] . $y . "\"\x{064C}\x{0648}", $_->[0] x $x . "\"iNU", $_->[1] . $y . "\"\x{064D}\x{0648}", ( $option{'non-refined'} ? () : ( $_->[0] x $x . "\"uNA", $_->[1] . $y . "\"\x{064C}\x{0627}", $_->[0] x $x . "\"iNA", $_->[1] . $y . "\"\x{064D}\x{0627}", $_->[0] x $x . "\"uNY", $_->[1] . $y . "\"\x{064C}\x{0649}", $_->[0] x $x . "\"iNY", $_->[1] . $y . "\"\x{064D}\x{0649}", $_->[0] x $x . "\"aNU", $_->[1] . $y . "\"\x{064B}\x{0648}", $_->[0] x $x . "\"aW-a", $_->[1] . $y . "\"\x{064E}\x{0648}\x{064E}\x{0627}", $_->[0] x $x . "\"aW-u", $_->[1] . $y . "\"\x{064E}\x{0648}\x{064F}\x{0627}", $_->[0] x $x . "\"aW-i", $_->[1] . $y . "\"\x{064E}\x{0648}\x{0650}\x{0627}", $_->[0] x $x . "\"aW-\"a", $_->[1] . $y . "\"\x{064E}\x{0648}\"\x{064E}\x{0627}", $_->[0] x $x . "\"aW-\"u", $_->[1] . $y . "\"\x{064E}\x{0648}\"\x{064F}\x{0627}", $_->[0] x $x . "\"aW-\"i", $_->[1] . $y . "\"\x{064E}\x{0648}\"\x{0650}\x{0627}", $_->[0] x $x . "aW-\"a", $_->[1] . $y . "\x{064E}\x{0648}\"\x{064E}\x{0627}", $_->[0] x $x . "aW-\"u", $_->[1] . $y . "\x{064E}\x{0648}\"\x{064F}\x{0627}", $_->[0] x $x . "aW-\"i", $_->[1] . $y . "\x{064E}\x{0648}\"\x{0650}\x{0627}", $_->[0] x $x . "\"aW-\"", $_->[1] . $y . "\"\x{064E}\x{0648}\"\x{0652}\x{0627}", $_->[0] x $x . "aW-\"", $_->[1] . $y . "\x{064E}\x{0648}\"\x{0652}\x{0627}", ) ), $_->[0] x $x . "\"a_W", $_->[1] . $y . "\"\x{064E}\x{0648}", $_->[0] x $x . "\"u_W", $_->[1] . $y . "\"\x{064F}\x{0648}", $_->[0] x $x . "\"i_W", $_->[1] . $y . "\"\x{0650}\x{0648}", $_->[0] x $x . "\"aW", $_->[1] . $y . "\"\x{064E}\x{0648}\x{0652}\x{0627}", $_->[0] x $x . "\"uW", $_->[1] . $y . "\"\x{064F}\x{0648}\x{0627}", $_->[0] x $x . "\"UW", $_->[1] . $y . "\"\x{064F}\x{0648}\x{0627}", $_->[0] x $x . "\"UA", $_->[1] . $y . "\"\x{064F}\x{0648}\x{0627}", ) ), } @sunny, @moony, $empty[0] } 0, 1 ), # taa' marbuu.ta endings ( map { $_->[0], $_->[1] . "\x{0652}", # "\xD9\x92" sukuun ( $option{'non-quoting'} ? () : ( $_->[0] . "\"", $_->[1] . "\"\x{0652}", # "\xD9\x92" sukuun ) ), } @taaaa ), ( map { my $fix = $_; $_->[0] . "a", $_->[1] . "\x{064E}", $_->[0] . "u", $_->[1] . "\x{064F}", $_->[0] . "i", $_->[1] . "\x{0650}", $_->[0] . "aN", $_->[1] . "\x{064B}", $_->[0] . "uN", $_->[1] . "\x{064C}", $_->[0] . "iN", $_->[1] . "\x{064D}", ( $option{'non-quoting'} ? () : ( $_->[0] . "\"a", $_->[1] . "\"\x{064E}", $_->[0] . "\"u", $_->[1] . "\"\x{064F}", $_->[0] . "\"i", $_->[1] . "\"\x{0650}", $_->[0] . "\"aN", $_->[1] . "\"\x{064B}", $_->[0] . "\"uN", $_->[1] . "\"\x{064C}", $_->[0] . "\"iN", $_->[1] . "\"\x{064D}", ) ), # non-voweled/sukuuned ( $option{'non-refined'} ? () : ( $_->[0] . "-a", $_->[1] . "\x{064E}", $_->[0] . "-u", $_->[1] . "\x{064F}", $_->[0] . "-i", $_->[1] . "\x{0650}", $_->[0] . "-aN", $_->[1] . "\x{064B}", $_->[0] . "-uN", $_->[1] . "\x{064C}", $_->[0] . "-iN", $_->[1] . "\x{064D}", ( $option{'non-quoting'} ? () : ( $_->[0] . "-\"a", $_->[1] . "\"\x{064E}", $_->[0] . "-\"u", $_->[1] . "\"\x{064F}", $_->[0] . "-\"i", $_->[1] . "\"\x{0650}", $_->[0] . "-\"aN", $_->[1] . "\"\x{064B}", $_->[0] . "-\"uN", $_->[1] . "\"\x{064C}", $_->[0] . "-\"iN", $_->[1] . "\"\x{064D}", ) ), ) ), map { ( $option{'non-refined'} ? () : ( $fix->[0] . "-a" . $_->[0], [ $fix->[1] . "\x{0652}", "a" . $_->[0] ], $fix->[0] . "-u" . $_->[0], [ $fix->[1] . "\x{0652}", "u" . $_->[0] ], $fix->[0] . "-i" . $_->[0], [ $fix->[1] . "\x{0652}", "i" . $_->[0] ], ( $option{'non-quoting'} ? () : ( $fix->[0] . "-\"a" . $_->[0], [ $fix->[1] . "\x{0652}\"", "a" . $_->[0] ], $fix->[0] . "-\"u" . $_->[0], [ $fix->[1] . "\x{0652}\"", "u" . $_->[0] ], $fix->[0] . "-\"i" . $_->[0], [ $fix->[1] . "\x{0652}\"", "i" . $_->[0] ], ) ), ) ), } @sunny, @moony, $empty[0] # @taaaa } $taaaa[0] ), # definite article assimilation .. non-linguistic ( map { $_->[0] . "-" . $_->[0], [ "\x{0644}", $_->[0] x 2 ], "l-" . $_->[0] x 2, [ "\x{0644}", $_->[0] x 2 ], } @sunny, @moony ), ( map { my $fix = $_; "l" . $_ . "-all", [ "", "l" . ( $_ eq "" ? "|" : $_ ) . "ll" ], "l" . $_ . "-al-", [ "", "l" . ( $_ eq "" ? "|" : $_ ) . "l-" ], "l" . $_ . "-al-l", [ "", "l" . $_ . "-ll" ], "l" . $_ . "-al-ll", [ "", "l" . $_ . "-ll" ], map { "l" . $fix . "-a" . $_->[0] . "-" . $_->[0], [ "", "l" . $fix . "l-" . $_->[0] x 2 ], "l" . $fix . "-al-" . $_->[0] x 2, [ "", "l" . $fix . "l-" . $_->[0] x 2 ], } @moony, grep { $_->[0] ne "l" } @sunny } "", "a", "u", "i", $option{'non-quoting'} ? () : ( "\"", "\"a", "\"u", "\"i" ) ), # initial vowels ( $option{'non-quoting'} ? () : ( "\"", "\x{0671}", # this grapheme is mode-dependent in the next level ) ), ( map { my $fix = $_; $_->[0] . "a", $_->[1] . "\x{064E}", $_->[0] . "u", $_->[1] . "\x{064F}", $_->[0] . "i", $_->[1] . "\x{0650}", ( $option{'non-refined'} ? () : ( $_->[0] . "_a", $_->[1] . "\x{0670}", $_->[0] . "_u", $_->[1] . "\x{0657}", $_->[0] . "_i", $_->[1] . "\x{0656}", $_->[0] . "_aA", $_->[1] . "\x{0670}\x{0627}", $_->[0] . "_aY", $_->[1] . "\x{0670}\x{0649}", $_->[0] . "_aU", $_->[1] . "\x{0670}\x{0648}", $_->[0] . "_aI", $_->[1] . "\x{0670}\x{064A}", ) ), $_->[0] . "A", $_->[1] . "\x{064E}\x{0627}", $_->[0] . "Y", $_->[1] . "\x{064E}\x{0649}", $_->[0] . "_I", $_->[1] . "\x{0650}\x{0627}", $_->[0] . "U", $_->[1] . "\x{064F}\x{0648}", $_->[0] . "I", $_->[1] . "\x{0650}\x{064A}", $_->[0] . "Uw", [ $_->[1] . "\x{064F}\x{0648}\x{0651}", "|" ], $_->[0] . "Iy", [ $_->[1] . "\x{0650}\x{064A}\x{0651}", "|" ], ( $option{'non-refined'} ? () : ( $_->[0] . "^A", "\x{0622}", # use no equivs $_->[0] . "^U", "\x{0623}\x{064F}\x{0648}", # use no equivs $_->[0] . "^I", "\x{0625}\x{0650}\x{064A}", # use no equivs ) ), $_->[0] . "aa", [ "", $_->[0] . "A" ], $_->[0] . "uw", [ "", $_->[0] . "U" ], $_->[0] . "iy", [ "", $_->[0] . "I" ], ( $option{'non-quoting'} ? () : ( $_->[0] . "\"a", $_->[1] . "\"\x{064E}", $_->[0] . "\"u", $_->[1] . "\"\x{064F}", $_->[0] . "\"i", $_->[1] . "\"\x{0650}", ( $option{'non-refined'} ? () : ( $_->[0] . "\"_a", $_->[1] . "\"\x{0670}", $_->[0] . "\"_u", $_->[1] . "\"\x{0657}", $_->[0] . "\"_i", $_->[1] . "\"\x{0656}", $_->[0] . "\"_aA", $_->[1] . "\"\x{0670}\x{0627}", $_->[0] . "\"_aY", $_->[1] . "\"\x{0670}\x{0649}", $_->[0] . "\"_aU", $_->[1] . "\"\x{0670}\x{0648}", $_->[0] . "\"_aI", $_->[1] . "\"\x{0670}\x{064A}", ) ), $_->[0] . "\"A", $_->[1] . "\"\x{064E}\x{0627}", $_->[0] . "\"Y", $_->[1] . "\"\x{064E}\x{0649}", $_->[0] . "\"A\"", $_->[1] . "\"\x{064E}\x{0627}\"\x{0652}", $_->[0] . "\"Y\"", $_->[1] . "\"\x{064E}\x{0649}\"\x{0652}", $_->[0] . "A\"", $_->[1] . "\x{064E}\x{0627}\"\x{0652}", $_->[0] . "Y\"", $_->[1] . "\x{064E}\x{0649}\"\x{0652}", $_->[0] . "\"_I", $_->[1] . "\"\x{0650}\x{0627}", $_->[0] . "\"_I\"", $_->[1] . "\"\x{0650}\x{0627}\"\x{0652}", $_->[0] . "_I\"", $_->[1] . "\x{0650}\x{0627}\"\x{0652}", $_->[0] . "\"U", $_->[1] . "\"\x{064F}\x{0648}", $_->[0] . "\"I", $_->[1] . "\"\x{0650}\x{064A}", $_->[0] . "\"U\"", $_->[1] . "\"\x{064F}\x{0648}\"\x{0652}", $_->[0] . "\"I\"", $_->[1] . "\"\x{0650}\x{064A}\"\x{0652}", $_->[0] . "U\"", $_->[1] . "\x{064F}\x{0648}\"\x{0652}", $_->[0] . "I\"", $_->[1] . "\x{0650}\x{064A}\"\x{0652}", $_->[0] . "\"Uw", [ $_->[1] . "\"\x{064F}\x{0648}\x{0651}", "|" ], $_->[0] . "\"Iy", [ $_->[1] . "\"\x{0650}\x{064A}\x{0651}", "|" ], ( $option{'non-refined'} ? () : ( $_->[0] . "\"^A", "\"\x{0622}", # use no equivs $_->[0] . "\"^U", "\"\x{0623}\x{064F}\x{0648}", # use no equivs $_->[0] . "\"^I", "\"\x{0625}\x{0650}\x{064A}", # use no equivs ) ), $_->[0] . "\"aa", [ "", $_->[0] . "\"A" ], $_->[0] . "\"uw", [ "", $_->[0] . "\"U" ], $_->[0] . "\"iy", [ "", $_->[0] . "\"I" ], ) ), ( map { $fix->[0] . "uw" . $_, [ $fix->[1] . "\x{064F}", "w" . $_ ], $fix->[0] . "iy" . $_, [ $fix->[1] . "\x{0650}", "y" . $_ ], ( $option{'non-quoting'} ? () : ( $fix->[0] . "\"uw" . $_, [ $fix->[1] . "\"\x{064F}", "w" . $_ ], $fix->[0] . "\"iy" . $_, [ $fix->[1] . "\"\x{0650}", "y" . $_ ], ) ), } "\"", qw "a u i A Y U I _I", $option{'non-refined'} ? () : qw "_a _u _i ^A ^U ^I" ), $_->[0] . "_aA'|aN", $_->[1] . "\x{0670}\x{0627}\x{0621}\x{064B}", $_->[0] . "A'|aN", $_->[1] . "\x{064E}\x{0627}\x{0621}\x{064B}", $_->[0] . "aN", $_->[1] . "\x{064B}", $_->[0] . "uN", $_->[1] . "\x{064C}", $_->[0] . "iN", $_->[1] . "\x{064D}", ( $option{'non-quoting'} ? () : ( $_->[0] . "\"_aA'|aN", $_->[1] . "\"\x{0670}\x{0627}\x{0621}\x{064B}", $_->[0] . "\"A'|aN", $_->[1] . "\"\x{064E}\x{0627}\x{0621}\x{064B}", $_->[0] . "\"_aA'|\"aN", $_->[1] . "\"\x{0670}\x{0627}\x{0621}\"\x{064B}", $_->[0] . "\"A'|\"aN", $_->[1] . "\"\x{064E}\x{0627}\x{0621}\"\x{064B}", $_->[0] . "_aA'|\"aN", $_->[1] . "\x{0670}\x{0627}\x{0621}\"\x{064B}", $_->[0] . "A'|\"aN", $_->[1] . "\x{064E}\x{0627}\x{0621}\"\x{064B}", $_->[0] . "\"A\"'|aN", $_->[1] . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\x{064B}", $_->[0] . "\"A\"'|\"aN", $_->[1] . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}", $_->[0] . "A\"'|\"aN", $_->[1] . "\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}", $_->[0] . "\"aN", $_->[1] . "\"\x{064B}", $_->[0] . "\"uN", $_->[1] . "\"\x{064C}", $_->[0] . "\"iN", $_->[1] . "\"\x{064D}", ) ), } $empty[1] ), # non-notation insertion escapes provided through ':xml' ); no strict 'refs'; ${ $cls . '::decoder' } = $decoder; if ($option{'describe'}) { $_->describe('') foreach @{${ $cls . '::decoder' }}; } $cls->demode(defined ${ $cls . '::demode' } ? ${ $cls . '::demode' } : 'default'); return ${ $cls . '::decoder' }; } sub eecoder ($@) { my $cls = shift @_; my $ext = shift @_; my %opt = @_ ? do { my $i = 0; map { ++$i % 2 ? lc $_ : $_ } @_ } : (); no strict 'refs'; my $refcoder = \${ $cls . '::' . $ext }; use strict 'refs'; if (exists $opt{'load'}) { if (ref \$opt{'load'} eq 'SCALAR') { if (my $done = do $opt{'load'}) { # file-define return ${$refcoder} = $done; } else { carp "Cannot parse " . $opt{'load'} . ": $@" if $@; carp "Cannot do " . $opt{'load'} . ": $!" unless defined $done; carp "Cannot run " . $opt{'load'}; return undef; } } elsif (UNIVERSAL::isa($opt{'load'}, 'CODE')) { return ${$refcoder} = $opt{'load'}->(); } elsif (UNIVERSAL::isa($opt{'load'}, 'ARRAY')) { if (grep { not $_->isa('Encode::Mapper') } @{$opt{'load'}}) { carp "Expecting a reference to an array of 'Encode::Mapper' objects"; return undef; } return ${$refcoder} = $opt{'load'}; } carp "Invalid type of the 'load' parameter, action ignored"; return undef; } if (exists $opt{'dump'}) { require Data::Dumper; my ($data, $i, @refs, @data); $data = Data::Dumper->new([${$refcoder}], [$ext]); for ($i = 0; $i < @{${$refcoder}}; $i++) { $refs[$i] = ['L', 'H', $ext . "->[$i]" ]; $data[$i] = ${$refcoder}->[$i]->dumper($refs[$i]); } if (ref \$opt{'dump'} eq 'SCALAR') { if ($opt{'dump'} =~ /^[A-Z][A-Za-z]*(\:\:[A-Z][A-Za-z]*)+$/) { my $class = $cls; for ($class, $opt{'dump'}) { $_ =~ s/\:\:/\//g; $_ .= '.pm'; } my $where = $INC{$class} =~ /^(.*)$class$/; $opt{'dump'} = $where . $opt{'dump'}; } elsif ($opt{'dump'} !~ s/^!// and -f $opt{'dump'}) { # 'SCALAR' carp "The file " . $opt{'dump'} . " exists, ignoring action"; return undef; } open my $file, '>', $opt{'dump'} or die $opt{'dump'}; print $file 'my ($L, $H, $' . $ext . ');'; for ($i = 0; $i < @{${$refcoder}}; $i++) { print $file $data[$i]->Useqq(1)->Indent(0)->Dump(); } print $file 'return $' . $ext . ';'; close $file; return ${$refcoder}; } elsif (UNIVERSAL::isa($opt{'dump'}, 'SCALAR')) { my $dump = ${$opt{'dump'}}; ${$opt{'dump'}} = $data; return ${$refcoder}; } } return -1; } sub enmode ($$) { my ($cls, $mode) = @_; $cls = blessed $cls if ref $cls; $mode = 'undef' unless defined $mode; $mode = $modemap{$mode} if exists $modemap{$mode}; no strict 'refs'; my $return = ${ $cls . '::enmode' }; ${ $cls . '::enmode' } = $mode if defined $mode; return $return unless defined ${ $cls . '::encoder' }; if (defined $mode) { $cls->enmoder($mode) unless defined ${ $cls . '::encoder' }->[$mode + $enlevel] or $mode == 0; ${ $cls . '::encoder' }->[$enlevel - 1] = ${ $cls . '::encoder' }->[$mode + $enlevel]; } return $return; } sub demode ($$) { my ($cls, $mode) = @_; $cls = blessed $cls if ref $cls; $mode = 'undef' unless defined $mode; $mode = $modemap{$mode} if exists $modemap{$mode}; no strict 'refs'; my $return = ${ $cls . '::demode' }; ${ $cls . '::demode' } = $mode if defined $mode; return $return unless defined ${ $cls . '::decoder' }; if (defined $mode) { $cls->demoder($mode) unless defined ${ $cls . '::decoder' }->[$mode + $delevel] or $mode == 0; ${ $cls . '::decoder' }->[$delevel - 1] = ${ $cls . '::decoder' }->[$mode + $delevel]; } return $return; } sub enmoder ($$@) { my ($cls, $mode) = @_; no strict 'refs'; return ${ $cls . '::encoder' }->[$mode + $enlevel] = undef; } sub demoder ($$@) { my ($cls, $mode) = @_; my $demoder = []; # rules for the fullvocalize mode $demoder->[4] = [ [ 'silent' => 0, ], "\x{0671}", "\x{0627}", "\"\x{0652}", "", "\"\x{064E}", "", "\"\x{064F}", "", "\"\x{0650}", "", "\"\x{064B}", "", "\"\x{064C}", "", "\"\x{064D}", "", "\"\x{0670}", "", "\"\x{0657}", "", "\"\x{0656}", "", "\"", "", "\x{064E}\x{0627}\"\x{0652}", "\x{064E}\x{0627}\x{0652}", "\"\x{064E}\x{0627}\"\x{0652}", "\x{0627}\x{0652}", ( ( $option{'font-fixing'} ? ( map { "\x{0644}" . $_ . "\x{064E}\x{0627}\"\x{0652}", "\x{0644}\x{0627}" . $_ . "\x{064E}\x{0652}", "\x{0644}" . $_ . "\"\x{064E}\x{0627}\"\x{0652}", "\x{0644}\x{0627}" . $_ . "\x{0652}", } "", "\x{0651}" ) : () ), ), "\x{064E}\x{0649}\"\x{0652}", "\x{064E}\x{0649}\x{0652}", "\"\x{064E}\x{0649}\"\x{0652}", "\x{0649}\x{0652}", "\x{064F}\x{0648}\"\x{0652}", "\x{064F}\x{0648}\x{0652}", "\"\x{064F}\x{0648}\"\x{0652}", "\x{0648}\x{0652}", "\x{0650}\x{064A}\"\x{0652}", "\x{0650}\x{064A}\x{0652}", "\"\x{0650}\x{064A}\"\x{0652}", "\x{064A}\x{0652}", # modern external/internal substitution with wa.sla ( map { my $vowel = $_; map { "\x{064E}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}" . $_ . "\x{0671}", "\"" . $vowel ], "\x{064F}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}" . $_ . "\x{0671}", "\"" . $vowel ], "\x{0650}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}" . $_ . "\x{0671}", "\"" . $vowel ], "\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0627}" . $_ . "\x{0671}", "\"" . $vowel ], "\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0649}" . $_ . "\x{0671}", "\"" . $vowel ], "\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}\x{0648}" . $_ . "\x{0671}", "\"" . $vowel ], "\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}\x{064A}" . $_ . "\x{0671}", "\"" . $vowel ], # quoted "\"\x{064E}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0671}", "\"" . $vowel ], "\"\x{064F}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0671}", "\"" . $vowel ], "\"\x{0650}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0671}", "\"" . $vowel ], "\"\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{0627}" . $_ . "\x{0671}", "\"" . $vowel ], "\"\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{0649}" . $_ . "\x{0671}", "\"" . $vowel ], "\"\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{0648}" . $_ . "\x{0671}", "\"" . $vowel ], "\"\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{064A}" . $_ . "\x{0671}", "\"" . $vowel ], "\"\x{064E}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ], "\"\x{064F}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ], "\"\x{0650}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ], "\"\x{064E}\x{0627}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0627}" . $_ . "\x{0627}", $vowel ], "\"\x{064E}\x{0649}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0649}" . $_ . "\x{0627}", $vowel ], "\"\x{064F}\x{0648}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0648}" . $_ . "\x{0627}", $vowel ], "\"\x{0650}\x{064A}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064A}" . $_ . "\x{0627}", $vowel ], "\x{064E}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}" . $_ . "\x{0627}", $vowel ], "\x{064F}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064F}" . $_ . "\x{0627}", $vowel ], "\x{0650}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0650}" . $_ . "\x{0627}", $vowel ], "\x{064E}\x{0627}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}\x{0627}" . $_ . "\x{0627}", $vowel ], "\x{064E}\x{0649}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}\x{0649}" . $_ . "\x{0627}", $vowel ], "\x{064F}\x{0648}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064F}\x{0648}" . $_ . "\x{0627}", $vowel ], "\x{0650}\x{064A}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0650}\x{064A}" . $_ . "\x{0627}", $vowel ], } "", "\x09", "\x0A", "\x0D", "\x20", "\x0D\x0A", "\x20\x20", "\x20\x20\x20", "\x20\x20\x20\x20" } "\x{064E}", "\x{064F}", "\x{0650}" ), # laam + 'alif .. either enforce ligatures, or shuffle the diacritics ( ( $option{'font-fixing'} ? ( map { my $alif = $_; map { my $vowel = $_; map { "\x{0644}" . $_ . $vowel . $alif, "\x{0644}" . $alif . $_ . $vowel, "\x{0644}" . $_ . "\"" . $vowel . $alif, "\x{0644}" . $alif . $_, } "", "\x{0651}" } "\x{064E}", "\x{064F}", "\x{0650}", "\x{064B}", "\x{064C}", "\x{064D}", "\x{0652}" } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}" #, "\x{0671}" ) : () ), ), ( ( $option{'font-fixing'} ? ( map { my $vowel = $_; map { "\x{0644}" . $_ . $vowel . "\x{0671}", "\x{0644}\x{0627}" . $_ . $vowel, "\x{0644}" . $_ . "\"" . $vowel . "\x{0671}", "\x{0644}\x{0627}" . $_, } "", "\x{0651}" } "\x{064E}", "\x{064F}", "\x{0650}", "\x{064B}", "\x{064C}", "\x{064D}", "\x{0652}" ) : () ), ), # laam + vowel + 'alif + vowel .. internal substitution with wa.sla ( ( $option{'font-fixing'} ? ( map { my $double = $_; map { my $vowel = $_; map { "\x{0644}" . $double . $vowel . "\x{0627}" . $_, [ "\x{0644}\x{0671}" . $double . $vowel, "\"" . $_ ], # quoted "\x{0644}" . $double . "\"" . $vowel . "\x{0627}" . $_, [ "\x{0644}\x{0671}" . $double, "\"" . $_ ], "\x{0644}" . $double . "\"" . $vowel . "\x{0627}\"" . $_, [ "\x{0644}\x{0627}" . $double, $_ ], "\x{0644}" . $double . $vowel . "\x{0627}\"" . $_, [ "\x{0644}\x{0627}" . $double . $vowel, $_ ], } "\x{064E}", "\x{064F}", "\x{0650}" } "\x{064E}", "\x{064F}", "\x{0650}" } "", "\x{0651}" ) : () ), ), # optional ligatures to enforce here ]; # rules for the vocalize mode $demoder->[3] = [ [ 'silent' => 0, ], "\"\x{0652}", "\x{0652}", "\"\x{064E}", "", "\"\x{064F}", "", "\"\x{0650}", "", "\"\x{064B}", "", "\"\x{064C}", "", "\"\x{064D}", "", "\"\x{0670}", "", "\"\x{0657}", "", "\"\x{0656}", "", "\x{0652}", "", "\"", "", # modern external/internal substitution with wa.sla ( map { my $vowel = $_; map { "\x{064E}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}" . $_ . "\x{0627}", "\"" . $vowel ], "\x{064F}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}" . $_ . "\x{0627}", "\"" . $vowel ], "\x{0650}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}" . $_ . "\x{0627}", "\"" . $vowel ], "\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0627}" . $_ . "\x{0627}", "\"" . $vowel ], "\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0649}" . $_ . "\x{0627}", "\"" . $vowel ], "\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}\x{0648}" . $_ . "\x{0627}", "\"" . $vowel ], "\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}\x{064A}" . $_ . "\x{0627}", "\"" . $vowel ], # quoted "\"\x{064E}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0627}", "\"" . $vowel ], "\"\x{064F}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0627}", "\"" . $vowel ], "\"\x{0650}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0627}", "\"" . $vowel ], "\"\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{0627}" . $_ . "\x{0627}", "\"" . $vowel ], "\"\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{0649}" . $_ . "\x{0627}", "\"" . $vowel ], "\"\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{0648}" . $_ . "\x{0627}", "\"" . $vowel ], "\"\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{064A}" . $_ . "\x{0627}", "\"" . $vowel ], "\"\x{064E}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ], "\"\x{064F}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ], "\"\x{0650}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ], "\"\x{064E}\x{0627}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0627}" . $_ . "\x{0627}", $vowel ], "\"\x{064E}\x{0649}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0649}" . $_ . "\x{0627}", $vowel ], "\"\x{064F}\x{0648}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0648}" . $_ . "\x{0627}", $vowel ], "\"\x{0650}\x{064A}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064A}" . $_ . "\x{0627}", $vowel ], "\x{064E}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}" . $_ . "\x{0627}", $vowel ], "\x{064F}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064F}" . $_ . "\x{0627}", $vowel ], "\x{0650}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0650}" . $_ . "\x{0627}", $vowel ], "\x{064E}\x{0627}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}\x{0627}" . $_ . "\x{0627}", $vowel ], "\x{064E}\x{0649}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}\x{0649}" . $_ . "\x{0627}", $vowel ], "\x{064F}\x{0648}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064F}\x{0648}" . $_ . "\x{0627}", $vowel ], "\x{0650}\x{064A}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0650}\x{064A}" . $_ . "\x{0627}", $vowel ], } "", "\x09", "\x0A", "\x0D", "\x20", "\x0D\x0A", "\x20\x20", "\x20\x20\x20", "\x20\x20\x20\x20" } "\x{064E}", "\x{064F}", "\x{0650}" ), # laam + 'alif .. either enforce ligatures, or shuffle the diacritics ( ( $option{'font-fixing'} ? ( map { my $alif = $_; map { my $vowel = $_; map { "\x{0644}" . $_ . $vowel . $alif, "\x{0644}" . $alif . $_ . $vowel, "\x{0644}" . $_ . "\"" . $vowel . $alif, "\x{0644}" . $alif . $_, } "", "\x{0651}" } "\x{064E}", "\x{064F}", "\x{0650}", "\x{064B}", "\x{064C}", "\x{064D}", # "\x{0652}" } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}", "\x{0671}" ) : () ), ), ( ( $option{'font-fixing'} ? ( map { my $alif = $_; map { "\x{0644}" . $_ . "\x{0652}" . $alif, "\x{0644}" . $alif . $_, "\x{0644}" . $_ . "\"\x{0652}" . $alif, "\x{0644}" . $alif . $_ . "\x{0652}", } "", "\x{0651}" } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}", "\x{0671}" ) : () ), ), # laam + vowel + 'alif + vowel .. internal substitution with wa.sla ( ( $option{'font-fixing'} ? ( map { my $double = $_; map { my $vowel = $_; map { "\x{0644}" . $double . $vowel . "\x{0627}" . $_, [ "\x{0644}\x{0627}" . $double . $vowel, "\"" . $_ ], # quoted "\x{0644}" . $double . "\"" . $vowel . "\x{0627}" . $_, [ "\x{0644}\x{0627}" . $double, "\"" . $_ ], "\x{0644}" . $double . "\"" . $vowel . "\x{0627}\"" . $_, [ "\x{0644}\x{0627}" . $double, $_ ], "\x{0644}" . $double . $vowel . "\x{0627}\"" . $_, [ "\x{0644}\x{0627}" . $double . $vowel, $_ ], } "\x{064E}", "\x{064F}", "\x{0650}" } "\x{064E}", "\x{064F}", "\x{0650}" } "", "\x{0651}" ) : () ), ), # optional ligatures to enforce here ]; # rules for the novocalize mode $demoder->[2] = [ [ 'silent' => 0, ], "\"\x{0652}", "\x{0652}", "\"\x{064E}", "\x{064E}", "\"\x{064F}", "\x{064F}", "\"\x{0650}", "\x{0650}", "\"\x{064B}", "\x{064B}", "\"\x{064C}", "\x{064C}", "\"\x{064D}", "\x{064D}", "\"\x{0670}", "\x{0670}", "\"\x{0657}", "\x{0657}", "\"\x{0656}", "\x{0656}", "\x{0652}", "", "\x{064E}", "", "\x{064F}", "", "\x{0650}", "", "\x{064B}", "", "\x{064C}", "", "\x{064D}", "", "\x{0670}", "", "\x{0657}", "", "\x{0656}", "", "\"", "", # modern internal substitution with "fictitious" wa.sla .. lam + vowel + 'alif + vowel below # modern external substitution with "fictitious" wa.sla # laam + 'alif .. either enforce ligatures, or shuffle the diacritics ( ( $option{'font-fixing'} ? ( map { my $alif = $_; map { my $vowel = $_; map { "\x{0644}" . $_ . $vowel . $alif, "\x{0644}" . $alif . $_, "\x{0644}" . $_ . "\"" . $vowel . $alif, "\x{0644}" . $alif . $_ . $vowel, } "", "\x{0651}" } "\x{064E}", "\x{064F}", "\x{0650}", "\x{064B}", "\x{064C}", "\x{064D}", "\x{0652}" } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}", "\x{0671}" ) : () ), ), # laam + vowel + 'alif + vowel .. internal substitution with wa.sla # optional ligatures to enforce here ]; # rules for the noshadda mode $demoder->[1] = [ [ 'silent' => 0, ], "\x{0651}", "", @{$demoder->[2]}[1 .. @{$demoder->[2]} - 1] ]; # original no-quotes rules $demoder->[0] = [ [ 'silent' => 0, ], # modern internal substitution with wa.sla .. lam + vowel + 'alif + vowel below ( map { my $vowel = $_; map { $vowel . "\x{0627}" . $_, $vowel . "\x{0671}", } "\x{064E}", "\x{064F}", "\x{0650}" } "\x{064E}", "\x{064F}", "\x{0650}" ), # modern external substitution with wa.sla ( map { my $vowel = $_; map { "\x{064E}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}" . $_, "\x{0671}" ], "\x{064F}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}" . $_, "\x{0671}" ], "\x{0650}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}" . $_, "\x{0671}" ], "\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0627}" . $_, "\x{0671}" ], "\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0649}" . $_, "\x{0671}" ], "\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}\x{0648}" . $_, "\x{0671}" ], "\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}\x{064A}" . $_, "\x{0671}" ], } "\x09", "\x0A", "\x0D", "\x20", "\x0D\x0A", "\x20\x20", "\x20\x20\x20", "\x20\x20\x20\x20" } "\x{064E}", "\x{064F}", "\x{0650}" ), # laam + 'alif .. either enforce ligatures, or shuffle the diacritics ( ( $option{'font-fixing'} ? ( map { my $alif = $_; map { my $vowel = $_; map { "\x{0644}" . $_ . $vowel . $alif, "\x{0644}" . $alif . $_ . $vowel, } "", "\x{0651}" } "\x{064E}", "\x{064F}", "\x{0650}", "\x{064B}", "\x{064C}", "\x{064D}", "\x{0652}" } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}", "\x{0671}" ) : () ), ), # laam + vowel + 'alif + vowel .. internal substitution with wa.sla ( ( $option{'font-fixing'} ? ( map { my $double = $_; map { my $vowel = $_; map { "\x{0644}" . $double . $vowel . "\x{0627}" . $_, "\x{0644}" . "\x{0671}" . $double . $vowel, } "\x{064E}", "\x{064F}", "\x{0650}" } "\x{064E}", "\x{064F}", "\x{0650}" } "", "\x{0651}" ) : () ), ), # optional ligatures to enforce here ]; no strict 'refs'; ${ $cls . '::decoder' }->[$mode + $delevel] = Encode::Mapper->compile(@{$demoder->[$mode]}); ${ $cls . '::decoder' }->[$mode + $delevel]->describe('') if $option{'describe'}; return ${ $cls . '::decoder' }->[$mode + $delevel]; } 1; __END__ =head1 NAME Encode::Arabic::ArabTeX - Interpreter of the ArabTeX notation of Arabic =head1 SYNOPSIS use Encode::Arabic::ArabTeX; # imports just like 'use Encode' would, plus extended options while ($line = <>) { # maps the ArabTeX notation for Arabic into the Arabic script print encode 'utf8', decode 'arabtex', $line; # 'ArabTeX' alias 'Lagally' alias 'TeX' } # ArabTeX lower ASCII transliteration <--> Arabic script in Perl's internal format $string = decode 'ArabTeX', $octets; $octets = encode 'ArabTeX', $string; Encode::Arabic::ArabTeX->encoder('dump' => '!./encoder.code'); # dump the encoder engine to file Encode::Arabic::ArabTeX->decoder('load'); # load the decoder engine from module's extra sources =head1 DESCRIPTION ArabTeX is an excellent extension to TeX/LaTeX designed for typesetting the right-to-left scripts of the Orient. It comes up with very intuitive and comprehensible lower ASCII transliterations, the expressive power of which is even better than that of the scripts. L implements the rules needed for proper interpretation of the ArabTeX notation of Arabic. The conversion ifself is done by L, and the user interface is built on the L module. =head2 ENCODING BUSINESS Since the ArabTeX notation is not a simple mapping to the graphemes of the Arabic script, encoding the script into the notation is ambiguous. Two different strings in the notation may correspond to identical strings in the script. Heuristics must be engaged to decide which of the representations is more appropriate. Together with this bottle-neck, encoding may not be perfectly invertible by the decode operation, due to over-generation or approximations in the encoding algorithm. There are situations where conversion from the Arabic script to the ArabTeX notation is still convenient and useful. Imagine you need to edit the data, enhance it with vowels or other diacritical marks, produce phonetic transcripts and trim the typography of the script ... Do it in the ArabTeX notation, having an unrivalled control over your acts! Nonetheless, encoding is not the very purpose for this module's existence ;) =head2 DECODING BUSINESS The module decodes the ArabTeX notation as defined in the User Manual Version 4.00 of March 11, 2004, L. The implementation uses three levels of L engines to solve the problem: =over =item I writing I carriers are determined from the context in accordance with the Arabic orthographical conventions. The first level of mapping expands every C<< <'> >> into the verbatim encoding of the relevant carrier. This level of processing can become optional, if people ever need to encode the I carriers explicitly. Interpretation of geminated I C<< <''> >> is B here, as opposed to ArabTeX itself. In order to deduce the proper spelling rules, we resorted to L and experimented with words like C<< >>, C<< >>, C<< >>, etc. On this level, word-internal occurrences of C<< >> get translated into C<< >>, which is an extension to the notation that simplifies some requirements in modeling of the Arabic morphology. =item Grapheme generation The core level includes most of the rules needed, and converts the ArabTeX notation to Arabic graphemes in Unicode. The engine recognizes all the consonants of Modern Standard Arabic, plus the following letters: [ "|", "" ], # invisible consonant [ "B", "\x{0640}" ], # consonantal ta.twil [ "T", "\x{0629}" ], # ta' marbu.ta [ "H", "\x{0629}" ], # ta' marbu.ta silent [ "p", "\x{067E}" ], # pa' [ "v", "\x{06A4}" ], # va' [ "g", "\x{06AF}" ], # gaf [ "c", "\x{0681}" ], # .ha with hamza [ "^c", "\x{0686}" ], # gim with three [ ",c", "\x{0685}" ], # _ha with three [ "^z", "\x{0698}" ], # zay with three [ "^n", "\x{06AD}" ], # kaf with three [ "^l", "\x{06B5}" ], # lam with bow above [ ".r", "\x{0695}" ], # ra' with bow below There are many nice features in the notation, like assimilation, gemination, hyphenation, all implemented here. Defective and historical writings of vowels are supported, too! Try yourself if your fonts can handle these ;) Word-initial sequences like C<< >>, C<< >>, C<< >> and C<< >>, where C stands for a short, possibly quoted or missing, vowel, and C represents a fixed consonant, are processed according to the requirements of the Arabic orthography. Thus, C<< >> reduces to C<< >>, C<< >> becomes C<< >>, and C<< >> equals C<< >>, while C<< >> turns into C<< >>. =item I and ligatures I is introduced if there is a preceding long or short vowel, and the blank space is one newline, one tabulator, or up to four single spaces. Optionally, diacritical marks in between I and I<'alif> go after the latter letter, since most of the current systems rendering the Arabic script do not produce the desired ligatures if the two kinds of graphemes are not adjacent immediately. =back There are modes and options in ArabTeX that have not been dealt with yet in L. Still, mutual consistency of the systems is very high. This new release does support B and works in the ArabTeX's C<\vocalize> mode by default. The other B are implemented, too, as described below within the C and C methods. =head2 EXPORTS, ENGINES & MODES The module exports as if C also appeared in the package. The C options, except for the first-place subsequence of C<:xml>, C<:simple> or C<:describe>, are just delegated to L and imports performed properly. If the first element in the list to C is C<:xml>, all XML markup, or rather any B the well-paired and non-nested B C<< < >> and C<< > >>, will be preserved. Properties of the L engines can be generally controlled through the L API. In case the next, possibly the first, element in this list is C<:simple>, B in the engines B so that quotes be mapped to empty strings and infrequent or experimental notations of vowels not be interpreted in the extra manner of ArabTeX. Using C<:simple> is recommended for simple every-day tasks where these nuances would have no impact and where full initialization would be bothering. The C<:describe> option calls the L's C method on the module's engines right after their compilation. Initialization of the engines takes place the first time they are used, unless they have already been defined. There are two explicit methods for it: =over =item encoder Initialize or redefine the encoder engine. If no parameters are given, rules in the module are compiled into a list of L objects. Currently, the C<--dump> and C<--load> options have some experimental meaning. =item decoder See the description of C. =back There are five B currently recognized in this module, and their aliases are mapped according to the module's C<%modemap> hash. Selection of the appropriate mode is done best through the C and C functions of L, or with a direct call of the namesake methods in L: our %Encode::Arabic::ArabTeX::modemap = ( # the module provides these definitions 'default' => 3, 'undef' => 0, 'fullvocalize' => 4, 'full' => 4, 'vocalize' => 3, 'nosukuun' => 3, 'novocalize' => 2, 'novowels' => 2, 'none' => 2, 'noshadda' => 1, 'noneplus' => 1, ); # the function calls might be preferred as more comfortable Encode::Arabic::demode 'arabtex', 'full'; # like 'encode' and 'decode' of Encode Encode::Arabic::ArabTeX->demode('fullvocalize'); # like the Encode::Encoding interfaces # how modes can be set easily use Encode::Arabic ':modes'; enmode 'arabtex', 'undef'; demode 'arabtex', 'noneplus'; =over =item enmode Currently in development. The mode is fixed to C<'undef'> internally. =item demode Enforces the proper version of the final, third level of the L engines. =back =head1 SEE ALSO L, L, L, L ArabTeX system L Klaus Lagally L ArabTeX extensions L ArabXeTeX L Encode Arabic: Exercise in Functional Parsing L =head1 AUTHOR Otakar Smrz C<< >>, L =head1 COPYRIGHT AND LICENSE Copyright (C) 2003-2010 Otakar Smrz This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Encode-Arabic-14.1/lib/Encode/Arabic/Parkinson.pm000444001750001750 1530612410623243 21545 0ustar00otakarotakar000000000000# ###################################################################### Otakar Smrz, 2003/01/23 # # Encoding of Arabic: Dil Parkinson's Notation ###################################### 2006/02/03 package Encode::Arabic::Parkinson; our $VERSION = '14.1'; use 5.008; use strict; use warnings; use Scalar::Util 'blessed'; use Encode::Encoding; use base 'Encode::Encoding'; __PACKAGE__->Define('Parkinson', 'Dil'); our $enmode; our $demode; our $optxml; our %modemap = ( 'default' => 0, 'undef' => 0, 'fullvocalize' => 0, 'full' => 0, 'nowasla' => 4, 'vocalize' => 3, 'nosukuun' => 3, 'novocalize' => 2, 'novowels' => 2, 'none' => 2, 'noshadda' => 1, 'noneplus' => 1, ); # use subs 'encoder', 'decoder'; # ignores later prototypes sub encoder ($); # respect prototypes sub decoder ($); # respect prototypes sub import { # perform import as if Encode were used one level before this module $optxml = defined $_[1] && $_[1] eq ':xml' ? 1 : 0; __PACKAGE__->enmode('full'); __PACKAGE__->demode('full'); splice @_, 1, 1; require Encode; push @Encode::ISA, 'Exporter' unless Encode->can('export_to_level'); Encode->export_to_level(1, @_); } sub encode ($$;$) { my (undef, $text, $check) = @_; $_[1] = '' if $check; # needed by in-place edit $text = encoder $text; $text = Encode::encode "utf8", $text if Encode::is_utf8($text); return $text; } sub decode ($$;$) { my (undef, $text, $check) = @_; $_[1] = '' if $check; # needed by in-place edit $text = Encode::decode "utf8", $text unless Encode::is_utf8($text); $text = decoder $text; return $text; } sub enmode ($$;$$) { my ($cls, $mode, $xml, $kshd) = @_; $cls = blessed $cls if ref $cls; $xml = $optxml unless defined $xml; $mode = 'undef' unless defined $mode; $mode = $modemap{$mode} if exists $modemap{$mode}; no strict 'refs'; my $return = ${ $cls . '::enmode' }; if (defined $mode) { ${ $cls . '::enmode' } = $mode; my @set = ( ( $kshd ? '' : q [\x{0640}] ) . q [\x{0623}\x{0624}\x{0625}] . q [\x{060C}\x{061B}\x{061F}] . q [\x{0621}\x{0622}\x{0626}-\x{063A}\x{0641}-\x{064A}] . q [\x{0660}-\x{0669}] . q [\x{0671}] . q [\x{0651}] . q [\x{064B}-\x{0650}\x{0670}] . q [\x{0652}] . ( $kshd ? q [\x{0640}] : '' ) , ( $kshd ? '' : q [_] ) . q [LWE] . q [,;?] . q [CMYAbQtVjHxdvrzspSDTZcgfqklmnhwey] . q [0-9] . ( $mode == 0 ? q [O] : q [A] ) . ( $mode == 1 ? '' : q [~] . ( $mode == 2 ? '' : q [NUIauiR] . ( $mode == 3 ? '' : q [o] ) ) ) ); undef &encoder; eval q / sub encoder ($) { $_[0] =~ tr[/ . $set[0] . q /] [/ . $set[1] . q /]d; return $_[0]; } /; } return $return; } sub demode ($$;$$) { my ($cls, $mode, $xml, $kshd) = @_; $cls = blessed $cls if ref $cls; $xml = $optxml unless defined $xml; $mode = 'undef' unless defined $mode; $mode = $modemap{$mode} if exists $modemap{$mode}; no strict 'refs'; my $return = ${ $cls . '::demode' }; if (defined $mode) { ${ $cls . '::demode' } = $mode; my @set = ( ( $kshd ? '' : q [_] ) . q [LWE] . q [,;?] . q [CMYAbQtVjHxdvrzspSDTZcgfqklmnhwey] . q [0-9] . q [O] . q [~] . q [NUIauiR] . q [o] . ( $kshd ? q [_] : '' ) , ( $kshd ? '' : q [\x{0640}] ) . q [\x{0623}\x{0624}\x{0625}] . q [\x{060C}\x{061B}\x{061F}] . q [\x{0621}\x{0622}\x{0626}-\x{063A}\x{0641}-\x{064A}] . q [\x{0660}-\x{0669}] . ( $mode == 0 ? q [\x{0671}] : q [\x{0627}] ) . ( $mode == 1 ? '' : q [\x{0651}] . ( $mode == 2 ? '' : q [\x{064B}-\x{0650}\x{0670}] . ( $mode == 3 ? '' : q [\x{0652}] ) ) ) ); undef &decoder; eval q / sub decoder ($) { $_[0] =~ tr[/ . $set[0] . q /] [/ . $set[1] . q /]d; return $_[0]; } /; } return $return; } 1; __END__ =head1 NAME Encode::Arabic::Parkinson - Dil Parkinson's transliteration of Arabic =head1 SYNOPSIS use Encode::Arabic::Parkinson; # imports just like 'use Encode' would, plus more while ($line = <>) { # Dil Parkinson's mapping into the Arabic script print encode 'utf8', decode 'parkinson', $line; # 'Parkinson' alias 'Dil' } # shell filter of data, e.g. in *n*x systems instead of viewing the Arabic script proper % perl -MEncode::Arabic::Parkinson -pe '$_ = encode "parkinson", decode "utf8", $_' =head1 DESCRIPTION Dil Parkinson's notation is a one-to-one transliteration of the Arabic script for Modern Standard Arabic, using lower ASCII characters to encode the graphemes of the original script. =head2 IMPLEMENTATION Similar to that in L. =head1 SEE ALSO L, L, L =head1 AUTHOR Otakar Smrz C<< >>, L =head1 COPYRIGHT AND LICENSE Copyright (C) 2003-2012 Otakar Smrz This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Encode-Arabic-14.1/lib/Encode/Arabic/CGI.pm000444001750001750 2437312410623243 20207 0ustar00otakarotakar000000000000# ###################################################################### Otakar Smrz, 2003/01/23 # # Encode Arabic Online ######################################################################### package Encode::Arabic::CGI; our $VERSION = '14.1'; use strict; use base 'CGI::Application::FastCGI'; use CGI::Fast ':standard'; use Benchmark; use Encode::Arabic; use Encode::Arabic::ArabTeX ':xml'; use Encode::Arabic::ArabTeX::ZDMG ':xml'; use Encode::Arabic::Buckwalter ':xml'; our $session; our %enc_hash = ( 'ArabTeX', 'ArabTeX', 'Buckwalter', 'Buckwalter', 'Habash-Soudi-Buckwalter', 'Habash', 'Parkinson', 'Parkinson', 'Unicode', 'UTF-8' ); our @dec_list = ('ArabTeX', 'Buckwalter', 'Habash-Soudi-Buckwalter', 'Parkinson', 'Unicode'); our @enc_list = ('Unicode', 'Buckwalter', 'Habash-Soudi-Buckwalter', 'Parkinson', 'ArabTeX'); our %url_hash = (); foreach (keys %enc_hash) { my $url = $enc_hash{$_}; $url =~ tr[-][/]; $url_hash{$_} = 'http://search.cpan.org/dist/Encode-Arabic/lib/Encode/Arabic/' . $url . '.pm'; } $url_hash{'Unicode'} = 'http://search.cpan.org/dist/Encode/Encode.pm'; sub setup { my $c = shift; $c->mode_param('runmode'); $c->start_mode('recode'); $c->error_mode('recode'); $c->run_modes(map { $_ => $_ } qw 'recode'); } sub cgiapp_prerun { $session++; } # use base 'CGI::Application::FastCGI'; sub run { my $self = shift; my $request = FCGI::Request(); $self->fastcgi($request); while ($request->Accept >= 0) { $self->reset_query; $self->CGI::Application::run; last if $self->reinit(); } } sub reinit { return -M $0 < 0; } sub escape ($) { my $x = shift; $x =~ s/\&/\&/g; $x =~ s/\/\>/g; return $x; } sub timer (@) { return sprintf "%04d/%02d/%02d %02d:%02d:%02d", $_[5] + 1900, $_[4] + 1, @_[3, 2, 1, 0]; } sub display_header ($) { my $c = shift; my $q = $c->query(); my $r; $q->charset('utf-8'); $r .= $q->start_html(-title => "Encode Arabic Online Interface", '-encoding' => $q->charset(), -style => {-src => 'http://quest.ms.mff.cuni.cz/encode/encode.css', '-type' => 'text/css'}, -script => {-src => 'http://quest.ms.mff.cuni.cz/encode/encode.js', -type => 'text/javascript'}); return $r; } sub display_headline ($) { my $c = shift; my $q = $c->query(); my $r; $r .= $q->h1($q->a({'href' => 'http://sourceforge.net/projects/encode-arabic/'}, "Encode Arabic"), 'Online Interface'); return $r; } sub display_welcome ($) { my $c = shift; my $q = $c->query(); my $r; $r .= $q->p("Welcome to the online interface to", $q->a({-href => 'http://sourceforge.net/projects/encode-arabic/'}, "Encode Arabic") . ", a library for processing various encodings and notations of Arabic with", $q->a({-href => 'http://search.cpan.org/dist/Encode-Arabic/'}, "Perl"), "or", $q->a({-href => 'http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Encode/'}, "Haskell") . "."); $r .= $q->p('You must have Unicode fonts installed to appreciate this site. If you need some, try the', $q->a({'href' => 'http://sourceforge.net/projects/dejavu/'}, 'DejaVu Fonts'), 'from SourceForge.'); return $r; } sub display_footline ($) { my $c = shift; my $q = $c->query(); my $r; $r .= $q->br(); $r .= $q->p("(C) Otakar Smr\x{017E} 2012-2003. GNU General Public License", $q->a({-href => 'http://www.gnu.org/licenses/'}, "GNU GPL 3") . "."); $r .= $q->p("Encode Arabic is an", $q->a({-href => 'http://sourceforge.net/projects/encode-arabic/'}, "open-source online"), "project.", "You can contribute to its development with your suggestions!"); $r .= $q->p("Contact", $q->a({-href => 'http://otakar-smrz.users.sf.net/'}, "otakar-smrz users.sf.net") . ",", "Institute of Formal and Applied Linguistics, Charles University in Prague."); return $r; } sub display_footer ($) { my $c = shift; my $q = $c->query(); my $r; $r .= $q->p({'style' => 'text-align: right;'}, 'Valid XHTML 1.0 Transitional', 'Valid CSS level 2.1'); $r .= $q->script({-type => 'text/javascript', -src => 'http://api.yamli.com/js/yamli_api.js'}, ""); $r .= $q->script({-type => 'text/javascript'}, join ' ', split ' ', q { if (typeof(Yamli) == "object") { Yamli.init({ uiLanguage: "en", startMode: "onOrUserDefault", settingsPlacement: 'inside', showTutorialLink: false, showDirectionLink: true }); encodeYamli(''); } }); $r .= $q->end_html(); return $r; } sub recode { my $c = shift; my $q = $c->query(); my $r = ''; my @tick = (); $q->param($c->mode_param(), 'recode'); $r .= display_header $c; $r .= display_headline $c; my @example = ( [ 'ArabTeX', "\\cap al-waqtu al-'Ana " . (timer gmtime time) . " bi-tawqIti , 'ah\"laN wa-sah\"laN!" ], [ 'ArabTeX', "\\cap iqra' h_a_dA an-na.s.sa bi-intibAhiN: li-al-laylaTayni yusAwI li-llaylatayni, wa-lA li-a|l-laylaT-|ayni." ], [ 'ArabTeX', "iqra'-i ad-darsa al-'awwala" ], [ 'Buckwalter', "AqrO Aldrs AlOwl" ], [ 'Buckwalter', "yEtbr mDy}A" ], [ 'Unicode', decode "buckwalter", "AqrO Aldrs AlOwl" ], [ 'Unicode', decode "buckwalter", "Aldrs AlOwl" ], [ 'Unicode', decode "buckwalter", "yEtbr mDy}A" ] ); if (defined $q->param('submit') and $q->param('submit') eq 'Example') { my $idx = rand @example; $q->param('text', $example[$idx][1]); $q->param('decode', $example[$idx][0]); } else { if (defined $q->param('text') and $q->param('text') != /^\s*$/) { $q->param('text', decode "utf8", $q->param('text')); $q->param('decode', @dec_list) unless defined $q->param('decode'); } else { $q->param('text', $example[0][1]); $q->param('decode', $example[0][0]); } } $q->param('encode', @enc_list) unless defined $q->param('encode'); $r .= display_welcome $c; $r .= $q->h2('Your Request'); $r .= $q->start_form('-method' => 'POST'); $r .= $q->table({-border => 0}, Tr({-align => 'left', -valign => 'middle'}, [ td({-colspan => 3}, [$q->textfield(-name => 'text', -default => $q->param('text'), -size => 120, -maxlength => 200, )]), td({-colspan => 3}, table({-border => 0, -width => "100%"}, Tr({-align => 'left', -valign => 'top'}, [ td({-align => 'left'}, 'Decode Setting') . td({-align => 'center'}, [$q->radio_group(-name => 'decode', -onchange => "encodeYamli('text')", -values => [@dec_list], -default => [$q->param('decode')]), ]), td({-align => 'left'}, 'Encode Setting') . td({-align => 'center'}, [$q->checkbox_group(-name => 'encode', -values => [@enc_list], -default => [$q->param('encode')]), ]), ]) )), ]), Tr({-align => 'left', -valign => 'middle'}, td({-align => 'left'}, $q->submit(-name => 'submit', -value => 'Submit')), td({-align => 'center'}, $q->reset('Reset')), td({-align => 'right'}, $q->submit(-name => 'submit', -value => 'Example')), )); $r .= $q->hidden( -name => $c->mode_param(), -value => $q->param($c->mode_param()) ); $r .= $q->end_form(); $r .= $q->h2('Decode'); $r .= $q->h3($q->a({'href' => $url_hash{$q->param('decode')}}, $q->param('decode'))); $r .= $q->p({'class' => $q->param('text') =~ /\p{Arabic}/ ? 'arabic' : ''}, $q->param('text') ne '' ? escape $q->param('text') : ' '); my $decode = decode $enc_hash{$q->param('decode')}, encode "utf8", $q->param('text'); $r .= $q->h2('Encode'); foreach ($q->param('encode')) { $r .= $q->h3($q->a({'href' => $url_hash{$_}}, $_)); my $encode = decode "utf8", encode $enc_hash{$_}, $decode; $r .= $q->p({'class' => $encode =~ /\p{Arabic}/ ? 'arabic' : ''}, $encode ne '' ? escape $encode : ' '); if ($_ eq 'Unicode' and $q->param('decode') eq 'ArabTeX') { my $encode = decode "arabtex-zdmg", encode "utf8", $q->param('text'); $r .= $q->p({'class' => $encode =~ /\p{Arabic}/ ? 'arabic' : ''}, $encode ne '' ? escape $encode : ' '); } } $r .= display_footline $c; $r .= display_footer $c; return encode "utf8", $r; } 1; Encode-Arabic-14.1/lib/Encode/Arabic/Habash.pm000444001750001750 1740612410623243 20772 0ustar00otakarotakar000000000000# ###################################################################### Otakar Smrz, 2003/01/23 # # Encoding of Arabic: Habash-Soudi-Buckwalter Notation ############################## 2003/06/19 package Encode::Arabic::Habash; our $VERSION = '14.1'; use 5.008; use strict; use warnings; use Scalar::Util 'blessed'; use Encode::Encoding; use base 'Encode::Encoding'; __PACKAGE__->Define('Habash', 'Soudi', 'HSB'); our $enmode; our $demode; our $optxml; our %modemap = ( 'default' => 0, 'undef' => 0, 'fullvocalize' => 0, 'full' => 0, 'nowasla' => 4, 'vocalize' => 3, 'nosukuun' => 3, 'novocalize' => 2, 'novowels' => 2, 'none' => 2, 'noshadda' => 1, 'noneplus' => 1, ); # use subs 'encoder', 'decoder'; # ignores later prototypes sub encoder ($); # respect prototypes sub decoder ($); # respect prototypes sub import { # perform import as if Encode were used one level before this module $optxml = defined $_[1] && $_[1] eq ':xml' ? 1 : 0; __PACKAGE__->enmode('full'); __PACKAGE__->demode('full'); splice @_, 1, 1; require Encode; push @Encode::ISA, 'Exporter' unless Encode->can('export_to_level'); Encode->export_to_level(1, @_); } sub encode ($$;$) { my (undef, $text, $check) = @_; $_[1] = '' if $check; # needed by in-place edit $text = encoder $text; $text = Encode::encode "utf8", $text if Encode::is_utf8($text); return $text; } sub decode ($$;$) { my (undef, $text, $check) = @_; $_[1] = '' if $check; # needed by in-place edit $text = Encode::decode "utf8", $text unless Encode::is_utf8($text); $text = decoder $text; return $text; } sub enmode ($$;$$) { my ($cls, $mode, $xml, $kshd) = @_; $cls = blessed $cls if ref $cls; $xml = $optxml unless defined $xml; $mode = 'undef' unless defined $mode; $mode = $modemap{$mode} if exists $modemap{$mode}; no strict 'refs'; my $return = ${ $cls . '::enmode' }; if (defined $mode) { ${ $cls . '::enmode' } = $mode; my @set = ( ( $kshd ? '' : q [\x{0640}] ) . q [\x{0623}\x{0624}\x{0625}] . q [\x{060C}\x{061B}\x{061F}] . q [\x{0621}\x{0622}\x{0626}-\x{063A}\x{0641}-\x{064A}] . q [\x{067E}\x{0686}\x{0698}\x{06A4}\x{06AF}] . q [\x{0660}-\x{0669}] . q [\x{0671}] . q [\x{0651}] . q [\x{064B}-\x{0650}\x{0670}] . q [\x{0652}] . ( $kshd ? q [\x{0640}] : '' ) , ( $kshd ? '' : q [\x{005F}] ) . q [\x{00C2}\x{0175}\x{01CD}] . q [\x{002C}\x{003B}\x{003F}] . q [\x{0027}\x{0100}\x{0177}\x{0041}\x{0062}\x{0127}\x{0074}\x{03B8}\x{006A}\x{0048}\x{0078}] . q [\x{0064}\x{00F0}\x{0072}\x{007A}\x{0073}\x{0161}\x{0053}\x{0044}\x{0054}\x{010E}\x{03C2}] . q [\x{03B3}\x{0066}\x{0071}\x{006B}\x{006C}\x{006D}\x{006E}\x{0068}\x{0077}\x{00FD}\x{0079}] . q [\x{0070}\x{0063}\x{017E}\x{0076}\x{0067}] . q [0-9] . ( $mode == 0 ? q [\x{00C4}] : q [\x{0041}] ) . ( $mode == 1 ? '' : q [\x{007E}] . ( $mode == 2 ? '' : q [\x{00E3}\x{0169}\x{0129}\x{0061}\x{0075}\x{0069}\x{00E1}] . ( $mode == 3 ? '' : q [\x{00B7}] ) ) ) ); undef &encoder; eval q / sub encoder ($) { $_[0] =~ tr[/ . $set[0] . q /] [/ . $set[1] . q /]d; return $_[0]; } /; } return $return; } sub demode ($$;$$) { my ($cls, $mode, $xml, $kshd) = @_; $cls = blessed $cls if ref $cls; $xml = $optxml unless defined $xml; $mode = 'undef' unless defined $mode; $mode = $modemap{$mode} if exists $modemap{$mode}; no strict 'refs'; my $return = ${ $cls . '::demode' }; if (defined $mode) { ${ $cls . '::demode' } = $mode; my @set = ( ( $kshd ? '' : q [\x{005F}] ) . q [\x{00C2}\x{0175}\x{01CD}] . q [\x{002C}\x{003B}\x{003F}] . q [\x{0027}\x{0100}\x{0177}\x{0041}\x{0062}\x{0127}\x{0074}\x{03B8}\x{006A}\x{0048}\x{0078}] . q [\x{0064}\x{00F0}\x{0072}\x{007A}\x{0073}\x{0161}\x{0053}\x{0044}\x{0054}\x{010E}\x{03C2}] . q [\x{03B3}\x{0066}\x{0071}\x{006B}\x{006C}\x{006D}\x{006E}\x{0068}\x{0077}\x{00FD}\x{0079}] . q [\x{0070}\x{0063}\x{017E}\x{0076}\x{0067}] . q [0-9] . q [\x{00C4}] . q [\x{007E}] . q [\x{00E3}\x{0169}\x{0129}\x{0061}\x{0075}\x{0069}\x{00E1}] . q [\x{00B7}] . ( $kshd ? q [\x{005F}] : '' ) , ( $kshd ? '' : q [\x{0640}] ) . q [\x{0623}\x{0624}\x{0625}] . q [\x{060C}\x{061B}\x{061F}] . q [\x{0621}\x{0622}\x{0626}-\x{063A}\x{0641}-\x{064A}] . q [\x{067E}\x{0686}\x{0698}\x{06A4}\x{06AF}] . q [\x{0660}-\x{0669}] . ( $mode == 0 ? q [\x{0671}] : q [\x{0627}] ) . ( $mode == 1 ? '' : q [\x{0651}] . ( $mode == 2 ? '' : q [\x{064B}-\x{0650}\x{0670}] . ( $mode == 3 ? '' : q [\x{0652}] ) ) ) ); undef &decoder; eval q / sub decoder ($) { $_[0] =~ tr[/ . $set[0] . q /] [/ . $set[1] . q /]d; return $_[0]; } /; } return $return; } 1; __END__ =head1 NAME Encode::Arabic::Habash - Habash-Soudi-Buckwalter transliteration of Arabic =head1 SYNOPSIS use Encode::Arabic::Habash; # imports just like 'use Encode' would, plus more while ($line = <>) { # Habash-Soudi-Buckwalter mapping into the Arabic script print encode 'utf8', decode 'habash', $line; # 'Habash' alias 'Soudi' alias 'HSB' } # shell filter of data, e.g. in *n*x systems instead of viewing the Arabic script proper % perl -MEncode::Arabic::Habash -pe '$_ = encode "habash", decode "utf8", $_' =head1 DESCRIPTION Habash-Soudi-Buckwalter notation is a one-to-one transliteration of the graphemes of the Arabic script into various symbols of Unicode defined in L. =head2 IMPLEMENTATION Similar to that in L. =head1 SEE ALSO L, L, L =head1 AUTHOR Otakar Smrz C<< >>, L =head1 COPYRIGHT AND LICENSE Copyright (C) 2003-2012 Otakar Smrz This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Encode-Arabic-14.1/lib/Encode/Arabic/Buckwalter.pm000444001750001750 2400112410623243 21674 0ustar00otakarotakar000000000000# ###################################################################### Otakar Smrz, 2003/01/23 # # Encoding of Arabic: Tim Buckwalter's Notation ##################################### 2003/06/19 package Encode::Arabic::Buckwalter; our $VERSION = '14.1'; use 5.008; use strict; use warnings; use Scalar::Util 'blessed'; use Encode::Encoding; use base 'Encode::Encoding'; __PACKAGE__->Define('Buckwalter', 'Tim'); our $enmode; our $demode; our $optxml; our %modemap = ( 'default' => 0, 'undef' => 0, 'fullvocalize' => 0, 'full' => 0, 'nowasla' => 4, 'vocalize' => 3, 'nosukuun' => 3, 'novocalize' => 2, 'novowels' => 2, 'none' => 2, 'noshadda' => 1, 'noneplus' => 1, ); # use subs 'encoder', 'decoder'; # ignores later prototypes sub encoder ($); # respect prototypes sub decoder ($); # respect prototypes sub import { # perform import as if Encode were used one level before this module $optxml = defined $_[1] && $_[1] eq ':xml' ? 1 : 0; __PACKAGE__->enmode('full'); __PACKAGE__->demode('full'); splice @_, 1, 1; require Encode; push @Encode::ISA, 'Exporter' unless Encode->can('export_to_level'); Encode->export_to_level(1, @_); } sub encode ($$;$) { my (undef, $text, $check) = @_; $_[1] = '' if $check; # needed by in-place edit $text = encoder $text; $text = Encode::encode "utf8", $text if Encode::is_utf8($text); return $text; } sub decode ($$;$) { my (undef, $text, $check) = @_; $_[1] = '' if $check; # needed by in-place edit $text = Encode::decode "utf8", $text unless Encode::is_utf8($text); $text = decoder $text; return $text; } sub enmode ($$;$$) { my ($cls, $mode, $xml, $kshd) = @_; $cls = blessed $cls if ref $cls; $xml = $optxml unless defined $xml; $mode = 'undef' unless defined $mode; $mode = $modemap{$mode} if exists $modemap{$mode}; no strict 'refs'; my $return = ${ $cls . '::enmode' }; if (defined $mode) { ${ $cls . '::enmode' } = $mode; my @set = ( ( $kshd ? '' : q [\x{0640}] ) . q [\x{0623}\x{0624}\x{0625}] . q [\x{060C}\x{061B}\x{061F}] . q [\x{0621}\x{0622}\x{0626}-\x{063A}\x{0641}-\x{064A}] . q [\x{067E}\x{0686}\x{0698}\x{06A4}\x{06AF}] . q [\x{0660}-\x{0669}] . q [\x{0671}] . q [\x{0651}] . q [\x{064B}-\x{0650}\x{0670}] . q [\x{0652}] . ( $kshd ? q [\x{0640}] : '' ) , ( $kshd ? '' : q [_] ) . ( $xml ? q [OWI] : q [>&<] ) . q [,;?] . q ['|}AbptvjHxd*rzs$SDTZEgfqklmnhwYy] . q [PJRVG] . q [0-9] . ( $mode == 0 ? q [{] : q [A] ) . ( $mode == 1 ? '' : q [~] . ( $mode == 2 ? '' : q [FNKaui`] . ( $mode == 3 ? '' : q [o] ) ) ) ); undef &encoder; eval q / sub encoder ($) { $_[0] =~ tr[/ . $set[0] . q /] [/ . $set[1] . q /]d; return $_[0]; } /; } return $return; } sub demode ($$;$$) { my ($cls, $mode, $xml, $kshd) = @_; $cls = blessed $cls if ref $cls; $xml = $optxml unless defined $xml; $mode = 'undef' unless defined $mode; $mode = $modemap{$mode} if exists $modemap{$mode}; no strict 'refs'; my $return = ${ $cls . '::demode' }; if (defined $mode) { ${ $cls . '::demode' } = $mode; my @set = ( ( $kshd ? '' : q [_] ) . ( $xml ? q [OWI] : q [>&<] ) . q [,;?] . q ['|}AbptvjHxd*rzs$SDTZEgfqklmnhwYy] . q [PJRVG] . q [0-9] . q [{] . q [~] . q [FNKaui`] . q [o] . ( $kshd ? q [_] : '' ) , ( $kshd ? '' : q [\x{0640}] ) . q [\x{0623}\x{0624}\x{0625}] . q [\x{060C}\x{061B}\x{061F}] . q [\x{0621}\x{0622}\x{0626}-\x{063A}\x{0641}-\x{064A}] . q [\x{067E}\x{0686}\x{0698}\x{06A4}\x{06AF}] . q [\x{0660}-\x{0669}] . ( $mode == 0 ? q [\x{0671}] : q [\x{0627}] ) . ( $mode == 1 ? '' : q [\x{0651}] . ( $mode == 2 ? '' : q [\x{064B}-\x{0650}\x{0670}] . ( $mode == 3 ? '' : q [\x{0652}] ) ) ) ); undef &decoder; eval q / sub decoder ($) { $_[0] =~ tr[/ . $set[0] . q /] [/ . $set[1] . q /]d; return $_[0]; } /; } return $return; } 1; __END__ =head1 NAME Encode::Arabic::Buckwalter - Tim Buckwalter's transliteration of Arabic =head1 SYNOPSIS use Encode::Arabic::Buckwalter; # imports just like 'use Encode' would, plus more while ($line = <>) { # Tim Buckwalter's mapping into the Arabic script print encode 'utf8', decode 'buckwalter', $line; # 'Buckwalter' alias 'Tim' } # shell filter of data, e.g. in *n*x systems instead of viewing the Arabic script proper % perl -MEncode::Arabic::Buckwalter -pe '$_ = encode "buckwalter", decode "utf8", $_' # employing the modes of conversion for filtering and trimming Encode::Arabic::enmode 'buckwalter', 'nosukuun', '>&< xml'; Encode::Arabic::Buckwalter->demode(undef, undef, 'strip _'); $decode = "Aiqora>o h`*aA {l_n~a_S~a bi___{notibaAhK."; $encode = encode 'buckwalter', decode 'buckwalter', $decode; # $encode eq "AiqraO h`*aA Aln~aS~a biAntibaAhK." =head1 DESCRIPTION Tim Buckwalter's notation is a one-to-one transliteration of the Arabic script for Modern Standard Arabic, using lower ASCII characters to encode the graphemes of the original script. This system has been very popular in Natural Language Processing, however, there are limits to its applicability due to numerous non-alphabetic codes involved. =head2 IMPLEMENTATION The module takes care of the L programming interface, while the effective code is Tim Buckwalter's Cick: $encode =~ tr[\x{060C}\x{061B}\x{061F}\x{0621}-\x{063A}\x{0640}-\x{0652} # !! no break in true perl !! \x{0670}\x{0671}\x{067E}\x{0686}\x{0698}\x{06A4}\x{06AF}\x{0660}-\x{0669}] [,;?'|>&<}AbptvjHxd*rzs$SDTZEg_fqklmnhwYyFNKaui~o`{PJRVG0-9]; $decode =~ tr[,;?'|>&<}AbptvjHxd*rzs$SDTZEg_fqklmnhwYyFNKaui~o`{PJRVG0-9] [\x{060C}\x{061B}\x{061F}\x{0621}-\x{063A}\x{0640}-\x{0652} # !! no break in true perl !! \x{0670}\x{0671}\x{067E}\x{0686}\x{0698}\x{06A4}\x{06AF}\x{0660}-\x{0669}]; =head2 EXPORTS & MODES If the first element in the list to C is C<:xml>, the alternative mapping is introduced that suits the B. This option is there only to replace the C<< >&< >> reserved characters by C while still having a one-to-one notation. There is no XML parsing involved, and the markup would get distorted if subject to C! $using_xml = eval q { use Encode::Arabic::Buckwalter ':xml'; decode 'buckwalter', 'OWI' }; $classical = eval q { use Encode::Arabic::Buckwalter; decode 'buckwalter', '>&<' }; # $classical eq $using_xml and $classical eq "\x{0623}\x{0624}\x{0625}" The module exports as if C also appeared in the package. The other C options are just delegated to L and imports performed properly. The B of this module allow to override the setting of the C<:xml> option, in addition to filtering out diacritical marks and stripping off I. The modes and aliases relate like this: our %Encode::Arabic::Buckwalter::modemap = ( 'default' => 0, 'undef' => 0, 'fullvocalize' => 0, 'full' => 0, 'nowasla' => 4, 'vocalize' => 3, 'nosukuun' => 3, 'novocalize' => 2, 'novowels' => 2, 'none' => 2, 'noshadda' => 1, 'noneplus' => 1, ); =over =item enmode (I<$obj,> $mode, $xml, $kshd) =item demode (I<$obj,> $mode, $xml, $kshd) These methods can be invoked directly or through the respective functions of L. The meaning of the extra parameters follows from the L. =back =head1 SEE ALSO L, L, L Tim Buckwalter's Qamus L Buckwalter Arabic Morphological Analyzer L =head1 AUTHOR Otakar Smrz C<< >>, L =head1 COPYRIGHT AND LICENSE Copyright (C) 2003-2012 Otakar Smrz This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Encode-Arabic-14.1/lib/Encode/Arabic/ArabTeX000755001750001750 012410623243 20347 5ustar00otakarotakar000000000000Encode-Arabic-14.1/lib/Encode/Arabic/ArabTeX/RE.pm000444001750001750 4477412410623243 21410 0ustar00otakarotakar000000000000# ################################################################### Otakar Smrz, 2003/01/23 # # Encoding of Arabic: ArabTeX Notation by Klaus Lagally ##################################### package Encode::Arabic::ArabTeX::RE; our $VERSION = '14.1'; use 5.008; use strict; use warnings; use Scalar::Util 'blessed'; use Encode::Encoding; use base 'Encode::Encoding'; __PACKAGE__->Define('ArabTeX-RE'); our (%encode_used, %decode_used, @shams, @qamar); our $enmode; our $demode; our %modemap = ( 'default' => 3, 'undef' => 0, 'fullvocalize' => 4, 'full' => 4, 'vocalize' => 3, 'nosukuun' => 3, 'novocalize' => 2, 'novowels' => 2, 'none' => 2, 'noshadda' => 1, 'noneplus' => 1, ); sub import { # perform import as if Encode were used one level before this module require Encode; push @Encode::ISA, 'Exporter' unless Encode->can('export_to_level'); Encode->export_to_level(1, @_); } sub encode ($$;$) { my ($cls, $text, $check) = @_; $_[1] = '' if $check; # this is what in-place edit needs $cls->initialize_encode() unless %encode_used; $text = join '', map { exists $encode_used{$_} ? $encode_used{$_} : $_ } split '', $text; $text =~ s/([\_\.\^]?\w)\\shadda{}/$1$1/g; $text =~ s/(\\ham{.})\\shadda{}/$1$1/g; $text =~ s/([\=\s\-\%])\\alif{}\\vow{a}l/$1"al-/g; $text =~ s/([\=\s\-\%])\\alif{}l/$1al-/g; $text =~ s/(b\\vow{i})\\alif{}l/$1-al-/g; $text =~ s/([\=\s\-\%])\\alif{}\\vow{([ui])}/$1"$2/g; $text =~ s/([\=\s\-\%])\\alif{}/$1i/g; $text =~ s/(\\vow{aN})\\alif{}/$1/g; $text =~ s/\\alif{}(\\vow{aN})/$1/g; $text =~ s/\\vow{a}\\alif{}/\\vow{A}/g; $text =~ s/\\alif{}/\\aux{A}/g; $text =~ s/\\madda{}/'A/g; $text =~ s/\\vow{a}\\maq{}/\\vow{Y}/g; $text =~ s/\\maq{}(\\vow{aN})/\\vow{aNY}/g; $text =~ s/\\vow{aN}\\maq{}/\\vow{aNY}/g; $text =~ s/\\maq{}/\\aux{Y}/g; $text =~ s/i(}?)y([^aiuAIUY])/I$1$2/g; # produces \ham{I}, too $text =~ s/u(}?)w([^aiuAIUY])/U$1$2/g; $text =~ s/([iIuU]})(\\ham{a})/$1-$2/g; $text =~ s/([\-\s])\\ham{a}([^\\])/$1'\\aux{a}$2/g; $text =~ s/([^\}\s])\\ham{a}/$1\\aux{a}'/g; $text =~ s/([^\-\s])(\\ham{i})/$1-$2/g; $text =~ s/\\ham{i}([^\\])/'\\aux{i}$1/g; $text =~ s/([^\}])(\\ham{w})/$1\\aux{u}$2/g; $text =~ s/(\\ham{w})([^\\])/$1\\aux{u}$2/g; $text =~ s/([^\}])(\\ham{y})/$1\\aux{i}$2/g; $text =~ s/(\\ham{y})([^\\])/$1\\aux{i}$2/g; $text =~ s/\\ham{[aiwy]}/'/g; $text =~ s/\\ham{I}/'I/g; $text =~ s/(?initialize_decode() unless %decode_used; $text = "\n" . $text . "\n"; $text =~ s/_a/a/g; # is there any special character for the defective fatha? $text =~ s/_U/U/g; # _U only affects the pronunciation, not the spelling foreach $one (@shams, '\\\'', @qamar) { $text =~ s/(?? $text =~ s/a'(\\D{})/a\\H{a}$1/g; # how do you write ? $text =~ s/'A/\\M{}/g; $text =~ s/'a/\\H{a}a/g; $text =~ s/'Y/\\H{a}Y/g; $text =~ s/'/\\H{a}a/g; # final resort foreach $one (@shams) { $text =~ s/($one)\-$one/l$1\\D{}/g; } foreach $one ('\\\\', @qamar) { $text =~ s/l\-($one)/l\\O{}$1/g; } # alas! using $one in the replacing expression produces extra \\ $text =~ s/aNY/\\V{aN}\\Q{}/g; $text =~ s/(?<=A\\H{}|\\H{a})aN/\\V{aN}/g; $text =~ s/(?<=T)aN/\\V{aN}/g; $text =~ s/(? "\x{0629}", "T", # C9 "\311", 'T', # 201 "\xC9", # "\xD8\xA9" "\x{062A}", "t", # CA "\312", 't', # 202 "\xCA", # "\xD8\xAA" "\x{062B}", "_t", # CB "\313", '\\_t', # 203 "\xCB", # "\xD8\xAB" <_t> "\x{062C}", "^g", # CC "\314", '\\^g', # 204 "\xCC", # "\xD8\xAC" <^g> "\x{062D}", ".h", # CD "\315", '\\.h', # 205 "\xCD", # "\xD8\xAD" <.h> "\x{062E}", "_h", # CE "\316", '\\_h', # 206 "\xCE", # "\xD8\xAE" <_h> "\x{062F}", "d", # CF "\317", 'd', # 207 "\xCF", # "\xD8\xAF" "\x{0630}", "_d", # D0 "\320", '\\_d', # 208 "\xD0", # "\xD8\xB0" <_d> "\x{0631}", "r", # D1 "\321", 'r', # 209 "\xD1", # "\xD8\xB1" "\x{0632}", "z", # D2 "\322", 'z', # 210 "\xD2", # "\xD8\xB2" "\x{0633}", "s", # D3 "\323", 's', # 211 "\xD3", # "\xD8\xB3" "\x{0634}", "^s", # D4 "\324", '\\^s', # 212 "\xD4", # "\xD8\xB4" <^s> "\x{0635}", ".s", # D5 "\325", '\\.s', # 213 "\xD5", # "\xD8\xB5" <.s> "\x{0636}", ".d", # D6 "\326", '\\.d', # 214 "\xD6", # "\xD8\xB6" <.d> # "\327", # D7 #"\327", "\x{0637}", ".t", # D8 "\330", '\\.t', # 216 "\xD8", # "\xD8\xB7" <.t> "\x{0638}", ".z", # D9 "\331", '\\.z', # 217 "\xD9", # "\xD8\xB8" <.z> "\x{0639}", "`", # DA "\332", '\\`', # 218 "\xDA", # "\xD8\xB9" <`> "\x{063A}", ".g", # DB "\333", '\\.g', # 219 "\xDB", # "\xD8\xBA" <.g> "\x{0640}", "-", # DC "\334", '--', # 220 "\xDC", # "\xD9\x80" ta.twiil "\x{0641}", "f", # DD "\335", 'f', # 221 "\xDD", # "\xD9\x81" "\x{0642}", "q", # DE "\336", 'q', # 222 "\xDE", # "\xD9\x82" "\x{0643}", "k", # DF "\337", 'k', # 223 "\xDF", # "\xD9\x83" # "\340", # E0 #"\340", "\x{0644}", "l", # E1 "\341", 'l', # 225 "\xE1", # "\xD9\x84" # "\342", # E2 #"\342", "\x{0645}", "m", # E3 "\343", 'm', # 227 "\xE3", # "\xD9\x85" "\x{0646}", "n", # E4 "\344", 'n', # 228 "\xE4", # "\xD9\x86" "\x{0647}", "h", # E5 "\345", 'h', # 229 "\xE5", # "\xD9\x87" "\x{0648}", "w", # E6 "\346", 'w', # 230 "\xE6", # "\xD9\x88" "\x{0649}", "\\maq{}", # EC "\354", '\\\\Q{}', # 236 "\xEC", # "\xD9\x89" 'alif maq.suura "\x{064A}", "y", # ED "\355", 'y', # 237 "\xED", # "\xD9\x8A" "\x{064B}", "\\vow{aN}", # F0 "\360", '\\\\V{aN}', # 240 "\xF0", # "\xD9\x8B" "\x{064C}", "\\vow{uN}", # F1 "\361", '\\\\V{uN}', # 241 "\xF1", # "\xD9\x8C" "\x{064D}", "\\vow{iN}", # F2 "\362", '\\\\V{iN}', # 242 "\xF2", # "\xD9\x8D" "\x{064E}", "\\vow{a}", # F3 "\363", '\\\\V{a}', # 243 "\xF3", # "\xD9\x8E" "\x{064F}", "\\vow{u}", # F5 "\365", '\\\\V{u}', # 245 "\xF5", # "\xD9\x8F" "\x{0650}", "\\vow{i}", # F6 "\366", '\\\\V{i}', # 246 "\xF6", # "\xD9\x90" "\x{0651}", "\\shadda{}", # F8 "\370", '\\\\D{}', # 248 "\xF8", # "\xD9\x91" ^sadda "\x{0652}", "\\sukun{}", # FA "\372", '\\\\O{}', # 250 "\xFA", # "\xD9\x92" sukuun "\x{0670}", # '\\\\A{}', # 243 "\xF3", # "\xD9\xB0" <_a> -> "\x{0671}", # '\\\\W{}', # 199 "\xC7", # "\xD9\xB1" wa.sla-on-'alif -> bare 'alif ); no strict 'refs'; $cls->enmode(defined ${ $cls . '::enmode' } ? ${ $cls . '::enmode' } : 'default'); } sub initialize_decode ($) { my $cls = shift @_; @shams = ('t', '\\_t', 'd', '\\_d', 'r', 'z', 's', '\\^s', '\\.s', '\\.d', '\\.t', '\\.z', 'l', 'n'); @qamar = ('b', '\\^g', '\\.h', '\\_h', '\\`', '\\.g', 'f', 'q', 'k', 'm', 'h', 'w', 'y'); %decode_used = ( # 'p', # 129 "\x81", # '\\^c', # 141 "\x8D", # '\\^z', # 142 "\x8E", # 'g', # 144 "\x90", '\\,', "\x{060C}", # 161 "\xA1", # "\xD8\x8C" right-to-left-comma '\\;', "\x{061B}", # 186 "\xBA", # "\xD8\x9B" right-to-left-semicolon '\\?', "\x{061F}", # 191 "\xBF", # "\xD8\x9F" right-to-left-question-mark '\\\\H{}', "\x{0621}", # 193 "\xC1", # "\xD8\xA1" hamza-on-the-line '\\\\M{}', "\x{0622}", # 194 "\xC2", # "\xD8\xA2" madda-over-'alif '\\\\H{a}', "\x{0623}", # 195 "\xC3", # "\xD8\xA3" hamza-over-'alif '\\\\H{w}', "\x{0624}", # 196 "\xC4", # "\xD8\xA4" hamza-over-waaw '\\\\H{i}', "\x{0625}", # 197 "\xC5", # "\xD8\xA5" hamza-under-'alif '\\\\H{y}', "\x{0626}", # 198 "\xC6", # "\xD8\xA6" hamza-over-yaa' '\\\\L{}', "\x{0627}", # 199 "\xC7", # "\xD8\xA7" bare 'alif 'b', "\x{0628}", # 200 "\xC8", # "\xD8\xA8" 'T', "\x{0629}", # 201 "\xC9", # "\xD8\xA9" 't', "\x{062A}", # 202 "\xCA", # "\xD8\xAA" '\\_t', "\x{062B}", # 203 "\xCB", # "\xD8\xAB" <_t> '\\^g', "\x{062C}", # 204 "\xCC", # "\xD8\xAC" <^g> '\\.h', "\x{062D}", # 205 "\xCD", # "\xD8\xAD" <.h> '\\_h', "\x{062E}", # 206 "\xCE", # "\xD8\xAE" <_h> 'd', "\x{062F}", # 207 "\xCF", # "\xD8\xAF" '\\_d', "\x{0630}", # 208 "\xD0", # "\xD8\xB0" <_d> 'r', "\x{0631}", # 209 "\xD1", # "\xD8\xB1" 'z', "\x{0632}", # 210 "\xD2", # "\xD8\xB2" 's', "\x{0633}", # 211 "\xD3", # "\xD8\xB3" '\\^s', "\x{0634}", # 212 "\xD4", # "\xD8\xB4" <^s> '\\.s', "\x{0635}", # 213 "\xD5", # "\xD8\xB5" <.s> '\\.d', "\x{0636}", # 214 "\xD6", # "\xD8\xB6" <.d> '\\.t', "\x{0637}", # 216 "\xD8", # "\xD8\xB7" <.t> '\\.z', "\x{0638}", # 217 "\xD9", # "\xD8\xB8" <.z> '\\`', "\x{0639}", # 218 "\xDA", # "\xD8\xB9" <`> '\\.g', "\x{063A}", # 219 "\xDB", # "\xD8\xBA" <.g> '--', "\x{0640}", # 220 "\xDC", # "\xD9\x80" ta.twiil 'f', "\x{0641}", # 221 "\xDD", # "\xD9\x81" 'q', "\x{0642}", # 222 "\xDE", # "\xD9\x82" 'k', "\x{0643}", # 223 "\xDF", # "\xD9\x83" 'l', "\x{0644}", # 225 "\xE1", # "\xD9\x84" 'm', "\x{0645}", # 227 "\xE3", # "\xD9\x85" 'n', "\x{0646}", # 228 "\xE4", # "\xD9\x86" 'h', "\x{0647}", # 229 "\xE5", # "\xD9\x87" 'w', "\x{0648}", # 230 "\xE6", # "\xD9\x88" '\\\\Q{}', "\x{0649}", # 236 "\xEC", # "\xD9\x89" 'alif maq.suura 'y', "\x{064A}", # 237 "\xED", # "\xD9\x8A" '\\\\V{aN}', "\x{064B}", # 240 "\xF0", # "\xD9\x8B" '\\\\V{uN}', "\x{064C}", # 241 "\xF1", # "\xD9\x8C" '\\\\V{iN}', "\x{064D}", # 242 "\xF2", # "\xD9\x8D" '\\\\V{a}', "\x{064E}", # 243 "\xF3", # "\xD9\x8E" '\\\\V{u}', "\x{064F}", # 245 "\xF5", # "\xD9\x8F" '\\\\V{i}', "\x{0650}", # 246 "\xF6", # "\xD9\x90" '\\\\D{}', "\x{0651}", # 248 "\xF8", # "\xD9\x91" ^sadda '\\\\O{}', "\x{0652}", # 250 "\xFA", # "\xD9\x92" sukuun '\\\\A{}', "\x{0670}", # 243 "\xF3", # "\xD9\xB0" <_a> -> '\\\\W{}', "\x{0671}", # 199 "\xC7", # "\xD9\xB1" wa.sla-on-'alif -> bare 'alif ); no strict 'refs'; $cls->demode(defined ${ $cls . '::demode' } ? ${ $cls . '::demode' } : 'default'); } sub enmode ($$) { my ($cls, $mode) = @_; $cls = blessed $cls if ref $cls; $mode = 'undef' unless defined $mode; $mode = $modemap{$mode} if exists $modemap{$mode}; no strict 'refs'; my $return = ${ $cls . '::enmode' }; ${ $cls . '::enmode' } = $mode; return $return; } sub demode ($$) { my ($cls, $mode) = @_; $cls = blessed $cls if ref $cls; $mode = 'undef' unless defined $mode; $mode = $modemap{$mode} if exists $modemap{$mode}; no strict 'refs'; my $return = ${ $cls . '::demode' }; ${ $cls . '::demode' } = $mode; return $return; } 1; __END__ =head1 NAME Encode::Arabic::ArabTeX::RE - Deprecated Encode::Arabic::ArabTeX implemented with regular expressions =head1 SYNOPSIS use Encode::Arabic::ArabTeX::RE; $string = decode 'arabtex-re', $octets; $octets = encode 'arabtex-re', $string; =head1 DESCRIPTION Deprecated method using sequential regular-expression substitutions. Limited in scope over the ArabTeX notation and non-efficient in data processing, still, not requiring the L module. =head2 EXPORTS & MODES Exports as if C also appeared in the package. Experimental and incomplete support for B is provided, see L. =head1 SEE ALSO L =head1 AUTHOR Otakar Smrz C<< >>, L =head1 COPYRIGHT AND LICENSE Copyright (C) 2003-2012 Otakar Smrz This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Encode-Arabic-14.1/lib/Encode/Arabic/ArabTeX/Verbatim.pm000444001750001750 21273312410623243 22663 0ustar00otakarotakar000000000000# ##################################################################### Otakar Smrz, 2005/07/16 # # Encoding of Arabic: ArabTeX Notation by Klaus Lagally, Verbatim ############################# package Encode::Arabic::ArabTeX::Verbatim; our $VERSION = '14.1'; use 5.008; use strict; use warnings; use Carp; use Encode::Arabic::ArabTeX (); use base 'Encode::Arabic::ArabTeX'; use Encode::Encoding; use base 'Encode::Encoding'; __PACKAGE__->Define('ArabTeX-Verbatim', 'ArabTeX-Verb'); use Encode::Mapper ':others', ':silent', ':join'; our %options; # records of options per package .. global register our %option; # options of the caller package .. used with local our $enmode; our $demode; our $enlevel = 2; our $delevel = 3; our %modemap = ( 'default' => 3, 'undef' => 0, 'fullvocalize' => 4, 'full' => 4, 'vocalize' => 3, 'nosukuun' => 3, 'novocalize' => 2, 'novowels' => 2, 'none' => 2, 'noshadda' => 1, 'noneplus' => 1, ); sub import { # perform import as if Encode were used one level before this module if (defined $_[1] and $_[1] eq ':xml') { # interfere little with possible Encode's options Encode::Mapper->options ( 'override' => [ # override rules of these LHS .. 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 ] ); splice @_, 1, 1; } if (defined $_[1] and $_[1] eq ':complex') { __PACKAGE__->options($_[1]); splice @_, 1, 1; } if (defined $_[1] and $_[1] eq ':describe') { __PACKAGE__->options($_[1]); splice @_, 1, 1; } require Encode; push @Encode::ISA, 'Exporter' unless Encode->can('export_to_level'); Encode->export_to_level(1, @_); } sub options ($%) { my $cls = shift @_; my ($i, $opt, %opt); my @returns = %option; $opt{'non-quoting'} = 0 unless defined $option{'non-quoting'}; $opt{'non-refined'} = 1 unless defined $option{'non-refined'}; while (@_) { $opt = lc shift @_; if ($opt =~ /^\:/) { $opt eq ':complex' and $opt{'non-quoting'} = 0, 1 and $opt{'non-refined'} = 0, 1 and next; $opt eq ':describe' and $opt{'describe'} = 1 and next; } else { $opt =~ /^\-*(.*)$/; $opt{$1} = shift @_; } } return %opt unless defined $cls; $option{$_} = $opt{$_} foreach keys %opt; return @returns; } sub encoder ($;%) { my ($cls, %opt) = @_; my $encoder = []; $encoder->[0] = Encode::Mapper->compile ( [ 'silent' => 0, ], ( map { chr 0x0660 + $_, "" . $_, } 0 .. 9 ), "\x{064B}", "aN", # 240 "\xF0", # "\xD9\x8B" "\x{064C}", "uN", # 241 "\xF1", # "\xD9\x8C" "\x{064D}", "iN", # 242 "\xF2", # "\xD9\x8D" "\x{064E}", "a", # 243 "\xF3", # "\xD9\x8E" "\x{064F}", "u", # 245 "\xF5", # "\xD9\x8F" "\x{0650}", "i", # 246 "\xF6", # "\xD9\x90" "\x{0670}", "_a", "\x{0657}", "_u", "\x{0656}", "_i", "\x{060C}", ",", # 161 "\xA1", # "\xD8\x8C" right-to-left-comma "\x{061B}", ";", # 186 "\xBA", # "\xD8\x9B" right-to-left-semicolon "\x{061F}", "?", # 191 "\xBF", # "\xD8\x9F" right-to-left-question-mark "\x{0621}", "'|", # 193 "\xC1", # "\xD8\xA1" hamza-on-the-line "\x{0622}", "'A", # 194 "\xC2", # "\xD8\xA2" madda-over-'alif "\x{0623}", "'a", # 195 "\xC3", # "\xD8\xA3" hamza-over-'alif "\x{0624}", "'w", # 196 "\xC4", # "\xD8\xA4" hamza-over-waaw "\x{0625}", "'i", # 197 "\xC5", # "\xD8\xA5" hamza-under-'alif "\x{0626}", "'y", # 198 "\xC6", # "\xD8\xA6" hamza-over-yaa' "\x{0627}", "A", # 199 "\xC7", # "\xD8\xA7" bare 'alif "\x{0628}", "b", # 200 "\xC8", # "\xD8\xA8" "\x{0629}", "T", # 201 "\xC9", # "\xD8\xA9" "\x{062A}", "t", # 202 "\xCA", # "\xD8\xAA" "\x{062B}", "_t", # 203 "\xCB", # "\xD8\xAB" <_t> "\x{062C}", "^g", # 204 "\xCC", # "\xD8\xAC" <^g> "\x{062D}", ".h", # 205 "\xCD", # "\xD8\xAD" <.h> "\x{062E}", "_h", # 206 "\xCE", # "\xD8\xAE" <_h> "\x{062F}", "d", # 207 "\xCF", # "\xD8\xAF" "\x{0630}", "_d", # 208 "\xD0", # "\xD8\xB0" <_d> "\x{0631}", "r", # 209 "\xD1", # "\xD8\xB1" "\x{0632}", "z", # 210 "\xD2", # "\xD8\xB2" "\x{0633}", "s", # 211 "\xD3", # "\xD8\xB3" "\x{0634}", "^s", # 212 "\xD4", # "\xD8\xB4" <^s> "\x{0635}", ".s", # 213 "\xD5", # "\xD8\xB5" <.s> "\x{0636}", ".d", # 214 "\xD6", # "\xD8\xB6" <.d> "\x{0637}", ".t", # 216 "\xD8", # "\xD8\xB7" <.t> "\x{0638}", ".z", # 217 "\xD9", # "\xD8\xB8" <.z> "\x{0639}", "`", # 218 "\xDA", # "\xD8\xB9" <`> "\x{063A}", ".g", # 219 "\xDB", # "\xD8\xBA" <.g> "\x{0640}", "--", # 220 "\xDC", # "\xD9\x80" ta.twiil "\x{0641}", "f", # 221 "\xDD", # "\xD9\x81" "\x{0642}", "q", # 222 "\xDE", # "\xD9\x82" "\x{0643}", "k", # 223 "\xDF", # "\xD9\x83" "\x{0644}", "l", # 225 "\xE1", # "\xD9\x84" "\x{0645}", "m", # 227 "\xE3", # "\xD9\x85" "\x{0646}", "n", # 228 "\xE4", # "\xD9\x86" "\x{0647}", "h", # 229 "\xE5", # "\xD9\x87" "\x{0648}", "w", # 230 "\xE6", # "\xD9\x88" "\x{0649}", "Y", # 236 "\xEC", # "\xD9\x89" 'alif maq.suura "\x{064A}", "y", # 237 "\xED", # "\xD9\x8A" "\x{0651}", "||", # 248 "\xF8", # "\xD9\x91" ^sadda "\x{0652}", "\"", # 250 "\xFA", # "\xD9\x92" sukuun "\x{0671}", "A", # 199 "\xC7", # "\xD9\xB1" wa.sla-on-'alif "\x{067E}", "p", "\x{06A4}", "v", "\x{06AF}", "g", "\x{0681}", "c", "\x{0686}", "^c", "\x{0685}", ",c", "\x{0698}", "^z", "\x{06AD}", "^n", "\x{06B5}", "^l", "\x{0695}", ".r", "\x{0640}\x{0651}", "|BB", ); no strict 'refs'; ${ $cls . '::encoder' } = $encoder; if ($option{'describe'}) { $_->describe('') foreach @{${ $cls . '::encoder' }}; } $cls->enmode(defined ${ $cls . '::enmode' } ? ${ $cls . '::enmode' } : 'default'); return ${ $cls . '::encoder' }; } sub decoder ($;$$) { my ($cls, undef, undef) = @_; my $decoder = []; my @sunny = ( [ "t", "\x{062A}" ], # "\xD8\xAA" [ "_t", "\x{062B}" ], # "\xD8\xAB" <_t> [ "d", "\x{062F}" ], # "\xD8\xAF" [ "_d", "\x{0630}" ], # "\xD8\xB0" <_d> [ "r", "\x{0631}" ], # "\xD8\xB1" [ "z", "\x{0632}" ], # "\xD8\xB2" [ "s", "\x{0633}" ], # "\xD8\xB3" [ "^s", "\x{0634}" ], # "\xD8\xB4" <^s> [ ".s", "\x{0635}" ], # "\xD8\xB5" <.s> [ ".d", "\x{0636}" ], # "\xD8\xB6" <.d> [ ".t", "\x{0637}" ], # "\xD8\xB7" <.t> [ ".z", "\x{0638}" ], # "\xD8\xB8" <.z> [ "l", "\x{0644}" ], # "\xD9\x84" [ "n", "\x{0646}" ], # "\xD9\x86" ); my @empty = ( [ "|", "" ], # ArabTeX's "invisible consonant" [ "", "\x{0627}" ], # "\xD8\xA7" bare 'alif ); my @taaaa = ( [ "T", "\x{0629}" ], # "\xD8\xA9" [ "H", "\x{0629}" ], # "\xD8\xA9" ); my @moony = ( [ "'A", "\x{0622}" ], # "\xD8\xA2" madda-over-'alif [ "'a", "\x{0623}" ], # "\xD8\xA3" hamza-over-'alif [ "'i", "\x{0625}" ], # "\xD8\xA5" hamza-under-'alif [ "'w", "\x{0624}" ], # "\xD8\xA4" hamza-over-waaw [ "'y", "\x{0626}" ], # "\xD8\xA6" hamza-over-yaa' [ "'|", "\x{0621}" ], # "\xD8\xA1" hamza-on-the-line [ "b", "\x{0628}" ], # "\xD8\xA8" [ "^g", "\x{062C}" ], # "\xD8\xAC" <^g> [ ".h", "\x{062D}" ], # "\xD8\xAD" <.h> [ "_h", "\x{062E}" ], # "\xD8\xAE" <_h> [ "`", "\x{0639}" ], # "\xD8\xB9" <`> [ ".g", "\x{063A}" ], # "\xD8\xBA" <.g> [ "f", "\x{0641}" ], # "\xD9\x81" [ "q", "\x{0642}" ], # "\xD9\x82" [ "k", "\x{0643}" ], # "\xD9\x83" [ "m", "\x{0645}" ], # "\xD9\x85" [ "h", "\x{0647}" ], # "\xD9\x87" [ "w", "\x{0648}" ], # "\xD9\x88" [ "y", "\x{064A}" ], # "\xD9\x8A" [ "B", "\x{0640}" ], # ArabTeX's "consonantal ta.twiil" [ "p", "\x{067E}" ], [ "v", "\x{06A4}" ], [ "g", "\x{06AF}" ], [ "c", "\x{0681}" ], # .ha with hamza [ "^c", "\x{0686}" ], # gim with three [ ",c", "\x{0685}" ], # _ha with three [ "^z", "\x{0698}" ], # zay with three [ "^n", "\x{06AD}" ], # kaf with three [ "^l", "\x{06B5}" ], # lam with a bow above [ ".r", "\x{0695}" ], # ra' with a bow below ); my @scope = ( "b", "t", "_t", "^g", ".h", "_h", "d", "_d", "r", "z", "s", "^s", ".s", ".d", ".t", ".z", "`", ".g", "f", "q", "k", "l", "m", "n", "h", "w", "p", "v", "g", "c", "^c", ",c", "^z", "^n", "^l", ".r", "|", "B", # "'", "y" treated specifically in some cases -- "T", "H" must as well ); $decoder->[0] = Encode::Mapper->compile ( [ 'silent' => 0, ], "_A", [ "", "Y" ], "_U", [ "", "U" ], "WA", [ "", "W" ], # word-internal occurrence "TA", [ "t", "A" ], "TU", [ "t", "U" ], "TI", [ "t", "I" ], "TY", [ "t", "Y" ], "T_A", [ "t", "_A" ], "T_U", [ "t", "_U" ], ( map { "T" . $_, [ "t", $_ ], "Ta" . $_, [ "t", "a" . $_ ], "Tu" . $_, [ "t", "u" . $_ ], "Ti" . $_, [ "t", "i" . $_ ], ( $option{'non-quoting'} ? () : ( "T\"" . $_, [ "t", "\"" . $_ ], "T\"a" . $_, [ "t", "\"a" . $_ ], "T\"u" . $_, [ "t", "\"u" . $_ ], "T\"i" . $_, [ "t", "\"i" . $_ ], ) ), } "'", @scope, "y" # "T", "H" ), # vowel-quoted sequences ( $option{'non-quoting'} ? ( "\"", "", # use non-quoting quotes only on no purpose ^^ ) : ( "\"", "\"", ) ), # general non-protection of \TeX directives ( map { "\\cap" . $_, [ "\\", "cap" . $_ ], } 'A' .. 'Z', 'a' .. 'z', '_', '0' .. '9' ), "\\", "\\", # strict \cap removal and white-space collapsing ( map { "\\cap" . $_ . "\x09", [ "", "\\cap " ], "\\cap" . $_ . "\x0A", [ "", "\\cap " ], "\\cap" . $_ . "\x0D", [ "", "\\cap " ], "\\cap" . $_ . "\x20", [ "", "\\cap " ], "\\cap" . $_, "", } "\x09", "\x0A", "\x0D", "\x20" ), "\\cap", "", # interfering rarely with the notation, or erroneous "^A", [ "^A", "|" ], "^I", [ "^I", "|" ], "^U", [ "^U", "|" ], "_a", [ "_a", "|" ], "_i", [ "_i", "|" ], "_u", [ "_u", "|" ], "_aA", [ "_aA", "|" ], "_aY", [ "_aY", "|" ], "_aU", [ "_aU", "|" ], "_aI", [ "_aI", "|" ], ); $decoder->[1] = Encode::Mapper->compile ( [ 'others' => undef, 'silent' => 0, ], # non-exciting entities "\x09", "\x09", "\x0A", "\x0A", "\x0D", "\x0D", " ", " ", ".", ".", ":", ":", "!", "!", "/", "/", "\\", "\\", ",", "\x{060C}", # "\xD8\x8C" right-to-left-comma ";", "\x{061B}", # "\xD8\x9B" right-to-left-semicolon "?", "\x{061F}", # "\xD8\x9F" right-to-left-question-mark "--", "\x{0640}", # "\xD9\x80" ta.twiil ( map { "" . $_, chr 0x0660 + $_, } 0 .. 9 ), # improper auxiliary vowels "-a", "", "-u", "", "-i", "", # explicit notations for ^sadda "||", [ "\x{0651}", "|" ], "|BB", [ "\x{0640}\x{0651}", "|" ], # non-voweled/sukuuned sunnies and moonies ( map { my $x = 1 + $_; my $y = "\x{0651}" x $_; # "\xD9\x91" ^sadda map { my $fix = $_; $_->[0] x $x, $_->[1] . $y . "\x{0652}", # "\xD9\x92" sukuun ( $option{'non-refined'} ? () : ( $_->[0] x $x . "-a", $_->[1] . $y . "\x{064E}", $_->[0] x $x . "-u", $_->[1] . $y . "\x{064F}", $_->[0] x $x . "-i", $_->[1] . $y . "\x{0650}", $_->[0] x $x . "-A", $_->[1] . $y . "\x{064E}\x{0627}", $_->[0] x $x . "-Y", $_->[1] . $y . "\x{064E}\x{0649}", $_->[0] x $x . "-U", $_->[1] . $y . "\x{064F}\x{0648}", $_->[0] x $x . "-I", $_->[1] . $y . "\x{0650}\x{064A}", $_->[0] x $x . "-aN", $_->[1] . $y . "\x{064B}" . ( $_->[0] eq "'a" ? "" : "\x{0627}" ), $_->[0] x $x . "-uN", $_->[1] . $y . "\x{064C}", $_->[0] x $x . "-iN", $_->[1] . $y . "\x{064D}", $_->[0] x $x . "-aNA", $_->[1] . $y . "\x{064B}\x{0627}", $_->[0] x $x . "-uNA", $_->[1] . $y . "\x{064C}\x{0627}", $_->[0] x $x . "-iNA", $_->[1] . $y . "\x{064D}\x{0627}", $_->[0] x $x . "-aNY", $_->[1] . $y . "\x{064B}\x{0649}", $_->[0] x $x . "-uNY", $_->[1] . $y . "\x{064C}\x{0649}", $_->[0] x $x . "-iNY", $_->[1] . $y . "\x{064D}\x{0649}", $_->[0] x $x . "-aNU", $_->[1] . $y . "\x{064B}\x{0648}", $_->[0] x $x . "-uNU", $_->[1] . $y . "\x{064C}\x{0648}", $_->[0] x $x . "-iNU", $_->[1] . $y . "\x{064D}\x{0648}", ) ), ( $option{'non-quoting'} ? () : ( $_->[0] x $x . "\"", $_->[1] . $y . "\"\x{0652}", # "\xD9\x92" sukuun ( $option{'non-refined'} ? () : ( $_->[0] x $x . "-\"a", $_->[1] . $y . "\"\x{064E}", $_->[0] x $x . "-\"u", $_->[1] . $y . "\"\x{064F}", $_->[0] x $x . "-\"i", $_->[1] . $y . "\"\x{0650}", $_->[0] x $x . "-\"A", $_->[1] . $y . "\"\x{064E}\x{0627}", $_->[0] x $x . "-\"Y", $_->[1] . $y . "\"\x{064E}\x{0649}", $_->[0] x $x . "-\"U", $_->[1] . $y . "\"\x{064F}\x{0648}", $_->[0] x $x . "-\"I", $_->[1] . $y . "\"\x{0650}\x{064A}", $_->[0] x $x . "-\"aN", $_->[1] . $y . "\"\x{064B}" . ( $_->[0] eq "'a" ? "" : "\x{0627}" ), $_->[0] x $x . "-\"uN", $_->[1] . $y . "\"\x{064C}", $_->[0] x $x . "-\"iN", $_->[1] . $y . "\"\x{064D}", $_->[0] x $x . "-\"aNA", $_->[1] . $y . "\"\x{064B}\x{0627}", $_->[0] x $x . "-\"uNA", $_->[1] . $y . "\"\x{064C}\x{0627}", $_->[0] x $x . "-\"iNA", $_->[1] . $y . "\"\x{064D}\x{0627}", $_->[0] x $x . "-\"aNY", $_->[1] . $y . "\"\x{064B}\x{0649}", $_->[0] x $x . "-\"uNY", $_->[1] . $y . "\"\x{064C}\x{0649}", $_->[0] x $x . "-\"iNY", $_->[1] . $y . "\"\x{064D}\x{0649}", $_->[0] x $x . "-\"aNU", $_->[1] . $y . "\"\x{064B}\x{0648}", $_->[0] x $x . "-\"uNU", $_->[1] . $y . "\"\x{064C}\x{0648}", $_->[0] x $x . "-\"iNU", $_->[1] . $y . "\"\x{064D}\x{0648}", ) ), ) ), map { ( $option{'non-refined'} ? () : ( $fix->[0] x $x . "-a" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "a" . $_->[0] ], $fix->[0] x $x . "-u" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "u" . $_->[0] ], $fix->[0] x $x . "-i" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "i" . $_->[0] ], $fix->[0] x $x . "-A" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "A" . $_->[0] ], $fix->[0] x $x . "-Y" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "Y" . $_->[0] ], $fix->[0] x $x . "-U" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "U" . $_->[0] ], $fix->[0] x $x . "-I" . $_->[0], [ $fix->[1] . $y . "\x{0652}", "I" . $_->[0] ], ( $option{'non-quoting'} ? () : ( $fix->[0] x $x . "-\"a" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "a" . $_->[0] ], $fix->[0] x $x . "-\"u" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "u" . $_->[0] ], $fix->[0] x $x . "-\"i" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "i" . $_->[0] ], $fix->[0] x $x . "-\"A" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "A" . $_->[0] ], $fix->[0] x $x . "-\"Y" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "Y" . $_->[0] ], $fix->[0] x $x . "-\"U" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "U" . $_->[0] ], $fix->[0] x $x . "-\"I" . $_->[0], [ $fix->[1] . $y . "\x{0652}\"", "I" . $_->[0] ], ) ), ) ), } @sunny, @moony, @taaaa, $empty[0] } @sunny, @moony[1 .. $#moony], $empty[0] # $moony[0] excluded as long as is unclear ^^ } 0 # 1 ), $moony[0]->[0], $moony[0]->[1], # now necessary of course ^^ # voweled/non-sukuuned sunnies and moonies ( map { my $x = 1 + $_; my $y = "\x{0651}" x $_; # "\xD9\x91" ^sadda map { my $fix = $_; $_->[0] x $x . "a", $_->[1] . $y . "\x{064E}", $_->[0] x $x . "u", $_->[1] . $y . "\x{064F}", $_->[0] x $x . "i", $_->[1] . $y . "\x{0650}", $_->[0] x $x . "_a", $_->[1] . $y . "\x{0670}", ( $option{'non-refined'} ? () : ( $_->[0] x $x . "_u", $_->[1] . $y . "\x{0657}", $_->[0] x $x . "_i", $_->[1] . $y . "\x{0656}", $_->[0] x $x . "_aA", $_->[1] . $y . "\x{0670}\x{0627}", $_->[0] x $x . "_aY", $_->[1] . $y . "\x{0670}\x{0649}", $_->[0] x $x . "_aU", $_->[1] . $y . "\x{0670}\x{0648}", $_->[0] x $x . "_aI", $_->[1] . $y . "\x{0670}\x{064A}", ) ), $_->[0] x $x . "A", $_->[1] . $y . "\x{064E}\x{0627}", $_->[0] x $x . "Y", $_->[1] . $y . "\x{064E}\x{0649}", $_->[0] x $x . "U", $_->[1] . $y . "\x{064F}\x{0648}", $_->[0] x $x . "I", $_->[1] . $y . "\x{0650}\x{064A}", $_->[0] x $x . "Uw", [ $_->[1] . $y . "\x{064F}", "ww" ], $_->[0] x $x . "Iy", [ $_->[1] . $y . "\x{0650}", "yy" ], ( $option{'non-refined'} ? () : ( $_->[0] x $x . "^A", $_->[1] . $y . "\x{064F}\x{0627}\x{0653}", $_->[0] x $x . "^U", $_->[1] . $y . "\x{064F}\x{0648}\x{0653}", $_->[0] x $x . "^I", $_->[1] . $y . "\x{0650}\x{064A}\x{0653}", $_->[0] x $x . "^Uw", [ $_->[1] . $y . "\x{064F}\x{0648}\x{0655}", "|" ], # roughly $_->[0] x $x . "^Iy", [ $_->[1] . $y . "\x{0650}\x{0649}\x{0655}", "|" ], # roughly ) ), $_->[0] x $x . "aa", [ "", $_->[0] x $x . "A" ], $_->[0] x $x . "uw", [ "", $_->[0] x $x . "U" ], $_->[0] x $x . "iy", [ "", $_->[0] x $x . "I" ], ( $option{'non-quoting'} ? () : ( $_->[0] x $x . "\"a", $_->[1] . $y . "\"\x{064E}", $_->[0] x $x . "\"u", $_->[1] . $y . "\"\x{064F}", $_->[0] x $x . "\"i", $_->[1] . $y . "\"\x{0650}", $_->[0] x $x . "\"_a", $_->[1] . $y . "\"\x{0670}", ( $option{'non-refined'} ? () : ( $_->[0] x $x . "\"_u", $_->[1] . $y . "\"\x{0657}", $_->[0] x $x . "\"_i", $_->[1] . $y . "\"\x{0656}", $_->[0] x $x . "\"_aA", $_->[1] . $y . "\"\x{0670}\x{0627}", $_->[0] x $x . "\"_aY", $_->[1] . $y . "\"\x{0670}\x{0649}", $_->[0] x $x . "\"_aU", $_->[1] . $y . "\"\x{0670}\x{0648}", $_->[0] x $x . "\"_aI", $_->[1] . $y . "\"\x{0670}\x{064A}", ) ), $_->[0] x $x . "\"A", $_->[1] . $y . "\"\x{064E}\x{0627}", $_->[0] x $x . "\"Y", $_->[1] . $y . "\"\x{064E}\x{0649}", $_->[0] x $x . "\"A\"", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}", $_->[0] x $x . "\"Y\"", $_->[1] . $y . "\"\x{064E}\x{0649}\"\x{0652}", $_->[0] x $x . "A\"", $_->[1] . $y . "\x{064E}\x{0627}\"\x{0652}", $_->[0] x $x . "Y\"", $_->[1] . $y . "\x{064E}\x{0649}\"\x{0652}", $_->[0] x $x . "\"U", $_->[1] . $y . "\"\x{064F}\x{0648}", $_->[0] x $x . "\"I", $_->[1] . $y . "\"\x{0650}\x{064A}", $_->[0] x $x . "\"U\"", $_->[1] . $y . "\"\x{064F}\x{0648}\"\x{0652}", $_->[0] x $x . "\"I\"", $_->[1] . $y . "\"\x{0650}\x{064A}\"\x{0652}", $_->[0] x $x . "U\"", $_->[1] . $y . "\x{064F}\x{0648}\"\x{0652}", $_->[0] x $x . "I\"", $_->[1] . $y . "\x{0650}\x{064A}\"\x{0652}", $_->[0] x $x . "\"Uw", [ $_->[1] . $y . "\"\x{064F}", "ww" ], $_->[0] x $x . "\"Iy", [ $_->[1] . $y . "\"\x{0650}", "yy" ], ( $option{'non-refined'} ? () : ( $_->[0] x $x . "\"^A", $_->[1] . $y . "\"\x{064F}\x{0627}\x{0653}", $_->[0] x $x . "\"^U", $_->[1] . $y . "\"\x{064F}\x{0648}\x{0653}", $_->[0] x $x . "\"^I", $_->[1] . $y . "\"\x{0650}\x{064A}\x{0653}", $_->[0] x $x . "\"^Uw", [ $_->[1] . $y . "\"\x{064F}\x{0648}\x{0655}", "|" ], # roughly $_->[0] x $x . "\"^Iy", [ $_->[1] . $y . "\"\x{0650}\x{0649}\x{0655}", "|" ], # roughly ) ), $_->[0] x $x . "\"aa", [ "", $_->[0] x $x . "\"A" ], $_->[0] x $x . "\"uw", [ "", $_->[0] x $x . "\"U" ], $_->[0] x $x . "\"iy", [ "", $_->[0] x $x . "\"I" ], ) ), ( map { $fix->[0] x $x . "uw" . $_, [ $fix->[1] . $y . "\x{064F}", "w" . $_ ], $fix->[0] x $x . "iy" . $_, [ $fix->[1] . $y . "\x{0650}", "y" . $_ ], ( $option{'non-quoting'} ? () : ( $fix->[0] x $x . "\"uw" . $_, [ $fix->[1] . $y . "\"\x{064F}", "w" . $_ ], $fix->[0] x $x . "\"iy" . $_, [ $fix->[1] . $y . "\"\x{0650}", "y" . $_ ], ) ), } "\"", qw "a u i A Y U I", $option{'non-refined'} ? () : qw "_a _u _i ^A ^U ^I" ), $_->[0] x $x . "_aA'|aN", $_->[1] . $y . "\x{0670}\x{0627}\x{0621}\x{064B}", $_->[0] x $x . "A'|aN", $_->[1] . $y . "\x{064E}\x{0627}\x{0621}\x{064B}", $_->[0] x $x . "aN", $_->[1] . $y . "\x{064B}" . ( $_->[0] eq "'a" ? "" : "\x{0627}" ), $_->[0] x $x . "uN", $_->[1] . $y . "\x{064C}", $_->[0] x $x . "iN", $_->[1] . $y . "\x{064D}", ( $option{'non-quoting'} ? () : ( $_->[0] x $x . "\"_aA'|aN", $_->[1] . $y . "\"\x{0670}\x{0627}\x{0621}\x{064B}", $_->[0] x $x . "\"A'|aN", $_->[1] . $y . "\"\x{064E}\x{0627}\x{0621}\x{064B}", $_->[0] x $x . "\"_aA'|\"aN", $_->[1] . $y . "\"\x{0670}\x{0627}\x{0621}\"\x{064B}", $_->[0] x $x . "\"A'|\"aN", $_->[1] . $y . "\"\x{064E}\x{0627}\x{0621}\"\x{064B}", $_->[0] x $x . "_aA'|\"aN", $_->[1] . $y . "\x{0670}\x{0627}\x{0621}\"\x{064B}", $_->[0] x $x . "A'|\"aN", $_->[1] . $y . "\x{064E}\x{0627}\x{0621}\"\x{064B}", $_->[0] x $x . "\"A\"'|aN", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\x{064B}", $_->[0] x $x . "\"A\"'|\"aN", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}", $_->[0] x $x . "A\"'|\"aN", $_->[1] . $y . "\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}", $_->[0] x $x . "\"aN", $_->[1] . $y . "\"\x{064B}" . ( $_->[0] eq "'a" ? "" : "\x{0627}" ), $_->[0] x $x . "\"uN", $_->[1] . $y . "\"\x{064C}", $_->[0] x $x . "\"iN", $_->[1] . $y . "\"\x{064D}", ) ), } @sunny, @moony, $empty[0] } 0 # 1 ), # 'alif protected endings ( map { my $x = 1 + $_; my $y = "\x{0651}" x $_; # "\xD9\x91" ^sadda map { $_->[0] x $x . "_aA'|aNA", $_->[1] . $y . "\x{0670}\x{0627}\x{0621}\x{064B}\x{0627}", $_->[0] x $x . "A'|aNA", $_->[1] . $y . "\x{064E}\x{0627}\x{0621}\x{064B}\x{0627}", $_->[0] x $x . "aNA", $_->[1] . $y . "\x{064B}\x{0627}", $_->[0] x $x . "aNY", $_->[1] . $y . "\x{064B}\x{0649}", ( $option{'non-refined'} ? () : ( $_->[0] x $x . "uNA", $_->[1] . $y . "\x{064C}\x{0627}", $_->[0] x $x . "iNA", $_->[1] . $y . "\x{064D}\x{0627}", $_->[0] x $x . "uNY", $_->[1] . $y . "\x{064C}\x{0649}", $_->[0] x $x . "iNY", $_->[1] . $y . "\x{064D}\x{0649}", $_->[0] x $x . "aNU", $_->[1] . $y . "\x{064B}\x{0648}", $_->[0] x $x . "uNU", $_->[1] . $y . "\x{064C}\x{0648}", $_->[0] x $x . "iNU", $_->[1] . $y . "\x{064D}\x{0648}", ) ), $_->[0] x $x . "aW", $_->[1] . $y . "\x{064E}\x{0648}\x{0652}\x{0627}", $_->[0] x $x . "UA", $_->[1] . $y . "\x{064F}\x{0648}\x{0627}", ( $option{'non-quoting'} ? () : ( $_->[0] x $x . "\"_aA'|aNA", $_->[1] . $y . "\"\x{0670}\x{0627}\x{0621}\x{064B}\x{0627}", $_->[0] x $x . "\"A'|aNA", $_->[1] . $y . "\"\x{064E}\x{0627}\x{0621}\x{064B}\x{0627}", $_->[0] x $x . "\"_aA'|\"aNA", $_->[1] . $y . "\"\x{0670}\x{0627}\x{0621}\"\x{064B}\x{0627}", $_->[0] x $x . "\"A'|\"aNA", $_->[1] . $y . "\"\x{064E}\x{0627}\x{0621}\"\x{064B}\x{0627}", $_->[0] x $x . "_aA'|\"aNA", $_->[1] . $y . "\x{0670}\x{0627}\x{0621}\"\x{064B}\x{0627}", $_->[0] x $x . "A'|\"aNA", $_->[1] . $y . "\x{064E}\x{0627}\x{0621}\"\x{064B}\x{0627}", $_->[0] x $x . "\"A\"'|aNA", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\x{064B}\x{0627}", $_->[0] x $x . "\"A\"'|\"aNA", $_->[1] . $y . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}\x{0627}", $_->[0] x $x . "A\"'|\"aNA", $_->[1] . $y . "\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}\x{0627}", $_->[0] x $x . "\"aNA", $_->[1] . $y . "\"\x{064B}\x{0627}", $_->[0] x $x . "\"aNY", $_->[1] . $y . "\"\x{064B}\x{0649}", ( $option{'non-refined'} ? () : ( $_->[0] x $x . "\"uNA", $_->[1] . $y . "\"\x{064C}\x{0627}", $_->[0] x $x . "\"iNA", $_->[1] . $y . "\"\x{064D}\x{0627}", $_->[0] x $x . "\"uNY", $_->[1] . $y . "\"\x{064C}\x{0649}", $_->[0] x $x . "\"iNY", $_->[1] . $y . "\"\x{064D}\x{0649}", $_->[0] x $x . "\"aNU", $_->[1] . $y . "\"\x{064B}\x{0648}", $_->[0] x $x . "\"uNU", $_->[1] . $y . "\"\x{064C}\x{0648}", $_->[0] x $x . "\"iNU", $_->[1] . $y . "\"\x{064D}\x{0648}", ) ), $_->[0] x $x . "\"aW", $_->[1] . $y . "\"\x{064E}\x{0648}\"\x{0652}\x{0627}", # coupled? $_->[0] x $x . "\"UA", $_->[1] . $y . "\"\x{064F}\x{0648}\x{0627}", ) ), } @sunny, @moony, $empty[0] } 0 # 1 ), # taa' marbuu.ta endings ( map { $_->[0], $_->[1] . "\x{0652}", # "\xD9\x92" sukuun ( $option{'non-quoting'} ? () : ( $_->[0] . "\"", $_->[1] . "\"\x{0652}", # "\xD9\x92" sukuun ) ), } @taaaa ), ( map { my $fix = $_; $_->[0] . "a", $_->[1] . "\x{064E}", $_->[0] . "u", $_->[1] . "\x{064F}", $_->[0] . "i", $_->[1] . "\x{0650}", $_->[0] . "aN", $_->[1] . "\x{064B}", $_->[0] . "uN", $_->[1] . "\x{064C}", $_->[0] . "iN", $_->[1] . "\x{064D}", ( $option{'non-quoting'} ? () : ( $_->[0] . "\"a", $_->[1] . "\"\x{064E}", $_->[0] . "\"u", $_->[1] . "\"\x{064F}", $_->[0] . "\"i", $_->[1] . "\"\x{0650}", $_->[0] . "\"aN", $_->[1] . "\"\x{064B}", $_->[0] . "\"uN", $_->[1] . "\"\x{064C}", $_->[0] . "\"iN", $_->[1] . "\"\x{064D}", ) ), # non-voweled/sukuuned ( $option{'non-refined'} ? () : ( $_->[0] . "-a", $_->[1] . "\x{064E}", $_->[0] . "-u", $_->[1] . "\x{064F}", $_->[0] . "-i", $_->[1] . "\x{0650}", $_->[0] . "-aN", $_->[1] . "\x{064B}", $_->[0] . "-uN", $_->[1] . "\x{064C}", $_->[0] . "-iN", $_->[1] . "\x{064D}", ( $option{'non-quoting'} ? () : ( $_->[0] . "-\"a", $_->[1] . "\"\x{064E}", $_->[0] . "-\"u", $_->[1] . "\"\x{064F}", $_->[0] . "-\"i", $_->[1] . "\"\x{0650}", $_->[0] . "-\"aN", $_->[1] . "\"\x{064B}", $_->[0] . "-\"uN", $_->[1] . "\"\x{064C}", $_->[0] . "-\"iN", $_->[1] . "\"\x{064D}", ) ), ) ), map { ( $option{'non-refined'} ? () : ( $fix->[0] . "-a" . $_->[0], [ $fix->[1] . "\x{0652}", "a" . $_->[0] ], $fix->[0] . "-u" . $_->[0], [ $fix->[1] . "\x{0652}", "u" . $_->[0] ], $fix->[0] . "-i" . $_->[0], [ $fix->[1] . "\x{0652}", "i" . $_->[0] ], ( $option{'non-quoting'} ? () : ( $fix->[0] . "-\"a" . $_->[0], [ $fix->[1] . "\x{0652}\"", "a" . $_->[0] ], $fix->[0] . "-\"u" . $_->[0], [ $fix->[1] . "\x{0652}\"", "u" . $_->[0] ], $fix->[0] . "-\"i" . $_->[0], [ $fix->[1] . "\x{0652}\"", "i" . $_->[0] ], ) ), ) ), } @sunny, @moony, $empty[0] # @taaaa } $taaaa[0] ), # initial vowels ( $option{'non-quoting'} ? () : ( "\"", "\x{0671}", # this grapheme is mode-dependent in the next level ) ), ( map { my $fix = $_; $_->[0] . "a", $_->[1] . "\x{064E}", $_->[0] . "u", $_->[1] . "\x{064F}", $_->[0] . "i", $_->[1] . "\x{0650}", ( $option{'non-refined'} ? () : ( $_->[0] . "_a", $_->[1] . "\x{0670}", $_->[0] . "_u", $_->[1] . "\x{0657}", $_->[0] . "_i", $_->[1] . "\x{0656}", $_->[0] . "_aA", $_->[1] . "\x{0670}\x{0627}", $_->[0] . "_aY", $_->[1] . "\x{0670}\x{0649}", $_->[0] . "_aU", $_->[1] . "\x{0670}\x{0648}", $_->[0] . "_aI", $_->[1] . "\x{0670}\x{064A}", ) ), $_->[0] . "A", "\x{0627}", $_->[0] . "Y", "\x{0649}", $_->[0] . "U", $_->[1] . "\x{064F}\x{0648}", $_->[0] . "I", $_->[1] . "\x{0650}\x{064A}", $_->[0] . "Uw", [ $_->[1] . "\x{064F}\x{0648}\x{0651}", "|" ], $_->[0] . "Iy", [ $_->[1] . "\x{0650}\x{064A}\x{0651}", "|" ], ( $option{'non-refined'} ? () : ( $_->[0] . "^A", "\x{0622}", # use no equivs $_->[0] . "^U", "\x{0623}\x{064F}\x{0648}", # use no equivs $_->[0] . "^I", "\x{0625}\x{0650}\x{064A}", # use no equivs ) ), $_->[0] . "aa", [ "", $_->[0] . "A" ], $_->[0] . "uw", [ "", $_->[0] . "U" ], $_->[0] . "iy", [ "", $_->[0] . "I" ], ( $option{'non-quoting'} ? () : ( $_->[0] . "\"a", $_->[1] . "\"\x{064E}", $_->[0] . "\"u", $_->[1] . "\"\x{064F}", $_->[0] . "\"i", $_->[1] . "\"\x{0650}", ( $option{'non-refined'} ? () : ( $_->[0] . "\"_a", $_->[1] . "\"\x{0670}", $_->[0] . "\"_u", $_->[1] . "\"\x{0657}", $_->[0] . "\"_i", $_->[1] . "\"\x{0656}", $_->[0] . "\"_aA", $_->[1] . "\"\x{0670}\x{0627}", $_->[0] . "\"_aY", $_->[1] . "\"\x{0670}\x{0649}", $_->[0] . "\"_aU", $_->[1] . "\"\x{0670}\x{0648}", $_->[0] . "\"_aI", $_->[1] . "\"\x{0670}\x{064A}", ) ), $_->[0] . "\"A", $_->[1] . "\"\x{064E}\x{0627}", $_->[0] . "\"Y", $_->[1] . "\"\x{064E}\x{0649}", $_->[0] . "\"A\"", $_->[1] . "\"\x{064E}\x{0627}\"\x{0652}", $_->[0] . "\"Y\"", $_->[1] . "\"\x{064E}\x{0649}\"\x{0652}", $_->[0] . "A\"", "\x{0627}\"\x{0652}", $_->[0] . "Y\"", "\x{0649}\"\x{0652}", $_->[0] . "\"U", $_->[1] . "\"\x{064F}\x{0648}", $_->[0] . "\"I", $_->[1] . "\"\x{0650}\x{064A}", $_->[0] . "\"U\"", $_->[1] . "\"\x{064F}\x{0648}\"\x{0652}", $_->[0] . "\"I\"", $_->[1] . "\"\x{0650}\x{064A}\"\x{0652}", $_->[0] . "U\"", $_->[1] . "\x{064F}\x{0648}\"\x{0652}", $_->[0] . "I\"", $_->[1] . "\x{0650}\x{064A}\"\x{0652}", $_->[0] . "\"Uw", [ $_->[1] . "\"\x{064F}\x{0648}\x{0651}", "|" ], $_->[0] . "\"Iy", [ $_->[1] . "\"\x{0650}\x{064A}\x{0651}", "|" ], ( $option{'non-refined'} ? () : ( $_->[0] . "\"^A", "\"\x{0622}", # use no equivs $_->[0] . "\"^U", "\"\x{0623}\x{064F}\x{0648}", # use no equivs $_->[0] . "\"^I", "\"\x{0625}\x{0650}\x{064A}", # use no equivs ) ), $_->[0] . "\"aa", [ "", $_->[0] . "\"A" ], $_->[0] . "\"uw", [ "", $_->[0] . "\"U" ], $_->[0] . "\"iy", [ "", $_->[0] . "\"I" ], ) ), ( map { $fix->[0] . "uw" . $_, [ $fix->[1] . "\x{064F}", "w" . $_ ], $fix->[0] . "iy" . $_, [ $fix->[1] . "\x{0650}", "y" . $_ ], ( $option{'non-quoting'} ? () : ( $fix->[0] . "\"uw" . $_, [ $fix->[1] . "\"\x{064F}", "w" . $_ ], $fix->[0] . "\"iy" . $_, [ $fix->[1] . "\"\x{0650}", "y" . $_ ], ) ), } "\"", qw "a u i A Y U I", $option{'non-refined'} ? () : qw "_a _u _i ^A ^U ^I" ), $_->[0] . "_aA'|aN", $_->[1] . "\x{0670}\x{0627}\x{0621}\x{064B}", $_->[0] . "A'|aN", $_->[1] . "\x{064E}\x{0627}\x{0621}\x{064B}", $_->[0] . "aN", $_->[1] . "\x{064B}", $_->[0] . "uN", $_->[1] . "\x{064C}", $_->[0] . "iN", $_->[1] . "\x{064D}", ( $option{'non-quoting'} ? () : ( $_->[0] . "\"_aA'|aN", $_->[1] . "\"\x{0670}\x{0627}\x{0621}\x{064B}", $_->[0] . "\"A'|aN", $_->[1] . "\"\x{064E}\x{0627}\x{0621}\x{064B}", $_->[0] . "\"_aA'|\"aN", $_->[1] . "\"\x{0670}\x{0627}\x{0621}\"\x{064B}", $_->[0] . "\"A'|\"aN", $_->[1] . "\"\x{064E}\x{0627}\x{0621}\"\x{064B}", $_->[0] . "_aA'|\"aN", $_->[1] . "\x{0670}\x{0627}\x{0621}\"\x{064B}", $_->[0] . "A'|\"aN", $_->[1] . "\x{064E}\x{0627}\x{0621}\"\x{064B}", $_->[0] . "\"A\"'|aN", $_->[1] . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\x{064B}", $_->[0] . "\"A\"'|\"aN", $_->[1] . "\"\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}", $_->[0] . "A\"'|\"aN", $_->[1] . "\x{064E}\x{0627}\"\x{0652}\x{0621}\"\x{064B}", $_->[0] . "\"aN", $_->[1] . "\"\x{064B}", $_->[0] . "\"uN", $_->[1] . "\"\x{064C}", $_->[0] . "\"iN", $_->[1] . "\"\x{064D}", ) ), } $empty[1] ), # non-notation insertion escapes provided through ':xml' ); no strict 'refs'; ${ $cls . '::decoder' } = $decoder; if ($option{'describe'}) { $_->describe('') foreach @{${ $cls . '::decoder' }}; } $cls->demode(defined ${ $cls . '::demode' } ? ${ $cls . '::demode' } : 'default'); return ${ $cls . '::decoder' }; } sub enmoder ($$@) { my ($cls, $mode) = @_; no strict 'refs'; return ${ $cls . '::encoder' }->[$mode + $enlevel] = undef; } sub demoder ($$@) { my ($cls, $mode) = @_; my $demoder = []; # rules for the fullvocalize mode $demoder->[4] = [ [ 'silent' => 0, ], "\x{0671}", "\x{0627}", "\"\x{0652}", "", "\"\x{064E}", "", "\"\x{064F}", "", "\"\x{0650}", "", "\"\x{064B}", "", "\"\x{064C}", "", "\"\x{064D}", "", "\"\x{0670}", "", "\"\x{0657}", "", "\"\x{0656}", "", "\"", "", "\x{064E}\x{0627}\"\x{0652}", "\x{064E}\x{0627}\x{0652}", "\"\x{064E}\x{0627}\"\x{0652}", "\x{0627}\x{0652}", ( ( $option{'font-fixing'} ? ( map { "\x{0644}" . $_ . "\x{064E}\x{0627}\"\x{0652}", "\x{0644}\x{0627}" . $_ . "\x{064E}\x{0652}", "\x{0644}" . $_ . "\"\x{064E}\x{0627}\"\x{0652}", "\x{0644}\x{0627}" . $_ . "\x{0652}", } "", "\x{0651}" ) : () ), ), "\x{064E}\x{0649}\"\x{0652}", "\x{064E}\x{0649}\x{0652}", "\"\x{064E}\x{0649}\"\x{0652}", "\x{0649}\x{0652}", "\x{064F}\x{0648}\"\x{0652}", "\x{064F}\x{0648}\x{0652}", "\"\x{064F}\x{0648}\"\x{0652}", "\x{0648}\x{0652}", "\x{0650}\x{064A}\"\x{0652}", "\x{0650}\x{064A}\x{0652}", "\"\x{0650}\x{064A}\"\x{0652}", "\x{064A}\x{0652}", # modern external/internal substitution with wa.sla ( map { my $vowel = $_; map { "\x{064E}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}" . $_ . "\x{0671}", "\"" . $vowel ], "\x{064F}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}" . $_ . "\x{0671}", "\"" . $vowel ], "\x{0650}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}" . $_ . "\x{0671}", "\"" . $vowel ], "\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0627}" . $_ . "\x{0671}", "\"" . $vowel ], "\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0649}" . $_ . "\x{0671}", "\"" . $vowel ], "\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}\x{0648}" . $_ . "\x{0671}", "\"" . $vowel ], "\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}\x{064A}" . $_ . "\x{0671}", "\"" . $vowel ], # quoted "\"\x{064E}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0671}", "\"" . $vowel ], "\"\x{064F}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0671}", "\"" . $vowel ], "\"\x{0650}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0671}", "\"" . $vowel ], "\"\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{0627}" . $_ . "\x{0671}", "\"" . $vowel ], "\"\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{0649}" . $_ . "\x{0671}", "\"" . $vowel ], "\"\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{0648}" . $_ . "\x{0671}", "\"" . $vowel ], "\"\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{064A}" . $_ . "\x{0671}", "\"" . $vowel ], "\"\x{064E}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ], "\"\x{064F}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ], "\"\x{0650}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ], "\"\x{064E}\x{0627}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0627}" . $_ . "\x{0627}", $vowel ], "\"\x{064E}\x{0649}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0649}" . $_ . "\x{0627}", $vowel ], "\"\x{064F}\x{0648}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0648}" . $_ . "\x{0627}", $vowel ], "\"\x{0650}\x{064A}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064A}" . $_ . "\x{0627}", $vowel ], "\x{064E}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}" . $_ . "\x{0627}", $vowel ], "\x{064F}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064F}" . $_ . "\x{0627}", $vowel ], "\x{0650}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0650}" . $_ . "\x{0627}", $vowel ], "\x{064E}\x{0627}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}\x{0627}" . $_ . "\x{0627}", $vowel ], "\x{064E}\x{0649}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}\x{0649}" . $_ . "\x{0627}", $vowel ], "\x{064F}\x{0648}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064F}\x{0648}" . $_ . "\x{0627}", $vowel ], "\x{0650}\x{064A}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0650}\x{064A}" . $_ . "\x{0627}", $vowel ], } "", "\x09", "\x0A", "\x0D", "\x20", "\x0D\x0A", "\x20\x20", "\x20\x20\x20", "\x20\x20\x20\x20" } "\x{064E}", "\x{064F}", "\x{0650}" ), # laam + 'alif .. either enforce ligatures, or shuffle the diacritics ( ( $option{'font-fixing'} ? ( map { my $alif = $_; map { my $vowel = $_; map { "\x{0644}" . $_ . $vowel . $alif, "\x{0644}" . $alif . $_ . $vowel, "\x{0644}" . $_ . "\"" . $vowel . $alif, "\x{0644}" . $alif . $_, } "", "\x{0651}" } "\x{064E}", "\x{064F}", "\x{0650}", "\x{064B}", "\x{064C}", "\x{064D}", "\x{0652}" } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}" #, "\x{0671}" ) : () ), ), ( ( $option{'font-fixing'} ? ( map { my $vowel = $_; map { "\x{0644}" . $_ . $vowel . "\x{0671}", "\x{0644}\x{0627}" . $_ . $vowel, "\x{0644}" . $_ . "\"" . $vowel . "\x{0671}", "\x{0644}\x{0627}" . $_, } "", "\x{0651}" } "\x{064E}", "\x{064F}", "\x{0650}", "\x{064B}", "\x{064C}", "\x{064D}", "\x{0652}" ) : () ), ), # laam + vowel + 'alif + vowel .. internal substitution with wa.sla ( ( $option{'font-fixing'} ? ( map { my $double = $_; map { my $vowel = $_; map { "\x{0644}" . $double . $vowel . "\x{0627}" . $_, [ "\x{0644}\x{0671}" . $double . $vowel, "\"" . $_ ], # quoted "\x{0644}" . $double . "\"" . $vowel . "\x{0627}" . $_, [ "\x{0644}\x{0671}" . $double, "\"" . $_ ], "\x{0644}" . $double . "\"" . $vowel . "\x{0627}\"" . $_, [ "\x{0644}\x{0627}" . $double, $_ ], "\x{0644}" . $double . $vowel . "\x{0627}\"" . $_, [ "\x{0644}\x{0627}" . $double . $vowel, $_ ], } "\x{064E}", "\x{064F}", "\x{0650}" } "\x{064E}", "\x{064F}", "\x{0650}" } "", "\x{0651}" ) : () ), ), # optional ligatures to enforce here ]; # rules for the vocalize mode $demoder->[3] = [ [ 'silent' => 0, ], "\"\x{0652}", "\x{0652}", "\"\x{064E}", "", "\"\x{064F}", "", "\"\x{0650}", "", "\"\x{064B}", "", "\"\x{064C}", "", "\"\x{064D}", "", "\"\x{0670}", "", "\"\x{0657}", "", "\"\x{0656}", "", "\x{0652}", "", "\"", "", # modern external/internal substitution with wa.sla ( map { my $vowel = $_; map { "\x{064E}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}" . $_ . "\x{0627}", "\"" . $vowel ], "\x{064F}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}" . $_ . "\x{0627}", "\"" . $vowel ], "\x{0650}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}" . $_ . "\x{0627}", "\"" . $vowel ], "\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0627}" . $_ . "\x{0627}", "\"" . $vowel ], "\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0649}" . $_ . "\x{0627}", "\"" . $vowel ], "\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}\x{0648}" . $_ . "\x{0627}", "\"" . $vowel ], "\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}\x{064A}" . $_ . "\x{0627}", "\"" . $vowel ], # quoted "\"\x{064E}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0627}", "\"" . $vowel ], "\"\x{064F}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0627}", "\"" . $vowel ], "\"\x{0650}" . $_ . "\x{0627}" . $vowel, [ $_ . "\x{0627}", "\"" . $vowel ], "\"\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{0627}" . $_ . "\x{0627}", "\"" . $vowel ], "\"\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{0649}" . $_ . "\x{0627}", "\"" . $vowel ], "\"\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{0648}" . $_ . "\x{0627}", "\"" . $vowel ], "\"\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{064A}" . $_ . "\x{0627}", "\"" . $vowel ], "\"\x{064E}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ], "\"\x{064F}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ], "\"\x{0650}" . $_ . "\x{0627}\"" . $vowel, [ $_ . "\x{0627}", $vowel ], "\"\x{064E}\x{0627}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0627}" . $_ . "\x{0627}", $vowel ], "\"\x{064E}\x{0649}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0649}" . $_ . "\x{0627}", $vowel ], "\"\x{064F}\x{0648}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0648}" . $_ . "\x{0627}", $vowel ], "\"\x{0650}\x{064A}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064A}" . $_ . "\x{0627}", $vowel ], "\x{064E}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}" . $_ . "\x{0627}", $vowel ], "\x{064F}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064F}" . $_ . "\x{0627}", $vowel ], "\x{0650}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0650}" . $_ . "\x{0627}", $vowel ], "\x{064E}\x{0627}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}\x{0627}" . $_ . "\x{0627}", $vowel ], "\x{064E}\x{0649}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064E}\x{0649}" . $_ . "\x{0627}", $vowel ], "\x{064F}\x{0648}" . $_ . "\x{0627}\"" . $vowel, [ "\x{064F}\x{0648}" . $_ . "\x{0627}", $vowel ], "\x{0650}\x{064A}" . $_ . "\x{0627}\"" . $vowel, [ "\x{0650}\x{064A}" . $_ . "\x{0627}", $vowel ], } "", "\x09", "\x0A", "\x0D", "\x20", "\x0D\x0A", "\x20\x20", "\x20\x20\x20", "\x20\x20\x20\x20" } "\x{064E}", "\x{064F}", "\x{0650}" ), # laam + 'alif .. either enforce ligatures, or shuffle the diacritics ( ( $option{'font-fixing'} ? ( map { my $alif = $_; map { my $vowel = $_; map { "\x{0644}" . $_ . $vowel . $alif, "\x{0644}" . $alif . $_ . $vowel, "\x{0644}" . $_ . "\"" . $vowel . $alif, "\x{0644}" . $alif . $_, } "", "\x{0651}" } "\x{064E}", "\x{064F}", "\x{0650}", "\x{064B}", "\x{064C}", "\x{064D}", # "\x{0652}" } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}", "\x{0671}" ) : () ), ), ( ( $option{'font-fixing'} ? ( map { my $alif = $_; map { "\x{0644}" . $_ . "\x{0652}" . $alif, "\x{0644}" . $alif . $_, "\x{0644}" . $_ . "\"\x{0652}" . $alif, "\x{0644}" . $alif . $_ . "\x{0652}", } "", "\x{0651}" } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}", "\x{0671}" ) : () ), ), # laam + vowel + 'alif + vowel .. internal substitution with wa.sla ( ( $option{'font-fixing'} ? ( map { my $double = $_; map { my $vowel = $_; map { "\x{0644}" . $double . $vowel . "\x{0627}" . $_, [ "\x{0644}\x{0627}" . $double . $vowel, "\"" . $_ ], # quoted "\x{0644}" . $double . "\"" . $vowel . "\x{0627}" . $_, [ "\x{0644}\x{0627}" . $double, "\"" . $_ ], "\x{0644}" . $double . "\"" . $vowel . "\x{0627}\"" . $_, [ "\x{0644}\x{0627}" . $double, $_ ], "\x{0644}" . $double . $vowel . "\x{0627}\"" . $_, [ "\x{0644}\x{0627}" . $double . $vowel, $_ ], } "\x{064E}", "\x{064F}", "\x{0650}" } "\x{064E}", "\x{064F}", "\x{0650}" } "", "\x{0651}" ) : () ), ), # optional ligatures to enforce here ]; # rules for the novocalize mode $demoder->[2] = [ [ 'silent' => 0, ], "\"\x{0652}", "\x{0652}", "\"\x{064E}", "\x{064E}", "\"\x{064F}", "\x{064F}", "\"\x{0650}", "\x{0650}", "\"\x{064B}", "\x{064B}", "\"\x{064C}", "\x{064C}", "\"\x{064D}", "\x{064D}", "\"\x{0670}", "\x{0670}", "\"\x{0657}", "\x{0657}", "\"\x{0656}", "\x{0656}", "\x{0652}", "", "\x{064E}", "", "\x{064F}", "", "\x{0650}", "", "\x{064B}", "", "\x{064C}", "", "\x{064D}", "", "\x{0670}", "", "\x{0657}", "", "\x{0656}", "", "\"", "", # modern internal substitution with "fictitious" wa.sla .. lam + vowel + 'alif + vowel below # modern external substitution with "fictitious" wa.sla # laam + 'alif .. either enforce ligatures, or shuffle the diacritics ( ( $option{'font-fixing'} ? ( map { my $alif = $_; map { my $vowel = $_; map { "\x{0644}" . $_ . $vowel . $alif, "\x{0644}" . $alif . $_, "\x{0644}" . $_ . "\"" . $vowel . $alif, "\x{0644}" . $alif . $_ . $vowel, } "", "\x{0651}" } "\x{064E}", "\x{064F}", "\x{0650}", "\x{064B}", "\x{064C}", "\x{064D}", "\x{0652}" } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}", "\x{0671}" ) : () ), ), # laam + vowel + 'alif + vowel .. internal substitution with wa.sla # optional ligatures to enforce here ]; # rules for the noshadda mode $demoder->[1] = [ [ 'silent' => 0, ], ]; # original no-quotes rules $demoder->[0] = [ [ 'silent' => 0, ], # modern internal substitution with wa.sla .. lam + vowel + 'alif + vowel below ( map { my $vowel = $_; map { $vowel . "\x{0627}" . $_, $vowel . "\x{0671}", } "\x{064E}", "\x{064F}", "\x{0650}" } "\x{064E}", "\x{064F}", "\x{0650}" ), # modern external substitution with wa.sla ( map { my $vowel = $_; map { "\x{064E}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}" . $_, "\x{0671}" ], "\x{064F}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}" . $_, "\x{0671}" ], "\x{0650}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}" . $_, "\x{0671}" ], "\x{064E}\x{0627}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0627}" . $_, "\x{0671}" ], "\x{064E}\x{0649}" . $_ . "\x{0627}" . $vowel, [ "\x{064E}\x{0649}" . $_, "\x{0671}" ], "\x{064F}\x{0648}" . $_ . "\x{0627}" . $vowel, [ "\x{064F}\x{0648}" . $_, "\x{0671}" ], "\x{0650}\x{064A}" . $_ . "\x{0627}" . $vowel, [ "\x{0650}\x{064A}" . $_, "\x{0671}" ], } "\x09", "\x0A", "\x0D", "\x20", "\x0D\x0A", "\x20\x20", "\x20\x20\x20", "\x20\x20\x20\x20" } "\x{064E}", "\x{064F}", "\x{0650}" ), # laam + 'alif .. either enforce ligatures, or shuffle the diacritics ( ( $option{'font-fixing'} ? ( map { my $alif = $_; map { my $vowel = $_; map { "\x{0644}" . $_ . $vowel . $alif, "\x{0644}" . $alif . $_ . $vowel, } "", "\x{0651}" } "\x{064E}", "\x{064F}", "\x{0650}", "\x{064B}", "\x{064C}", "\x{064D}", "\x{0652}" } "\x{0622}", "\x{0623}", "\x{0625}", "\x{0627}", "\x{0671}" ) : () ), ), # laam + vowel + 'alif + vowel .. internal substitution with wa.sla ( ( $option{'font-fixing'} ? ( map { my $double = $_; map { my $vowel = $_; map { "\x{0644}" . $double . $vowel . "\x{0627}" . $_, "\x{0644}" . "\x{0671}" . $double . $vowel, } "\x{064E}", "\x{064F}", "\x{0650}" } "\x{064E}", "\x{064F}", "\x{0650}" } "", "\x{0651}" ) : () ), ), # optional ligatures to enforce here ]; no strict 'refs'; ${ $cls . '::decoder' }->[$mode + $delevel] = Encode::Mapper->compile(@{$demoder->[$mode]}); ${ $cls . '::decoder' }->[$mode + $delevel]->describe('') if $option{'describe'}; return ${ $cls . '::decoder' }->[$mode + $delevel]; } 1; __END__ =head1 NAME Encode::Arabic::ArabTeX::Verbatim - Interpreter of the Verbatim variant of the ArabTeX notation =head1 SYNOPSIS use Encode::Arabic::ArabTeX::Verbatim; # imports just like 'use Encode' would, plus extended options while ($line = <>) { # maps the ArabTeX notation for Arabic into the Arabic script print encode 'utf8', decode 'arabtex-verb', $line; # 'ArabTeX-Verbatim' alias 'ArabTeX-Verb' } # ArabTeX language-dependent transliteration <--> ArabTeX verbatim transliteration $string = decode 'ArabTeX-Verbatim', $octets; $octets = encode 'ArabTeX-Verbatim', $string; =head1 DESCRIPTION ArabTeX is an excellent extension to TeX/LaTeX designed for typesetting the right-to-left scripts of the Orient. It comes up with very intuitive and comprehensible lower ASCII transliterations, the expressive power of which is even better than that of the scripts. L implements the rules needed for proper interpretation of the ArabTeX verbatim notation, which is discussed in the ArabTeX User Manual. The conversion ifself is done by L, and the user interface is built on the L module. Relevant guidance is given in L, from which this module inherits. The transformation rules are, however, quite different ;) This work is presented in its B! =head1 SEE ALSO L, L, L, L, L ArabTeX system L Klaus Lagally L =head1 AUTHOR Otakar Smrz C<< >>, L =head1 COPYRIGHT AND LICENSE Copyright (C) 2005-2008 Otakar Smrz This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Encode-Arabic-14.1/lib/Encode/Arabic/ArabTeX/ZDMG.pm000444001750001750 6131512410623243 21631 0ustar00otakarotakar000000000000# ##################################################################### Otakar Smrz, 2003/08/05 # # Encoding of Arabic: ArabTeX Notation by Klaus Lagally, ZDMG ################################# package Encode::Arabic::ArabTeX::ZDMG; our $VERSION = '14.1'; use 5.008; use strict; use warnings; use Carp; use Encode::Arabic::ArabTeX (); use base 'Encode::Arabic::ArabTeX'; use Encode::Encoding; use base 'Encode::Encoding'; __PACKAGE__->Define('ZDMG', 'ArabTeX-ZDMG'); use Encode::Mapper ':others', ':silent', ':join'; our %options; # records of options per package .. global register our %option; # options of the caller package .. used with local sub import { # perform import as if Encode were used one level before this module if (defined $_[1] and $_[1] eq ':xml') { # interfere little with possible Encode's options Encode::Mapper->options ( 'override' => [ # override rules of these LHS .. 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 ] ); splice @_, 1, 1; } if (defined $_[1] and $_[1] eq ':describe') { __PACKAGE__->options($_[1]); splice @_, 1, 1; } require Encode; push @Encode::ISA, 'Exporter' unless Encode->can('export_to_level'); Encode->export_to_level(1, @_); } sub encoder ($;%) { my ($cls, %opt) = @_; my $encoder = []; $encoder->[0] = Encode::Mapper->compile ( [ 'silent' => 0, ], "\x{0054}", "\\cap t", "\x{0074}", "t", "\x{1E6E}", "\\cap _t", "\x{1E6F}", "_t", "\x{0054}\x{0331}", "\\cap _t", "\x{0074}\x{0331}", "_t", "\x{0044}", "\\cap d", "\x{0064}", "d", "\x{1E0E}", "\\cap _d", "\x{1E0F}", "_d", "\x{0044}\x{0331}", "\\cap _d", "\x{0064}\x{0331}", "_d", "\x{0052}", "\\cap r", "\x{0072}", "r", "\x{005A}", "\\cap z", "\x{007A}", "z", "\x{0053}", "\\cap s", "\x{0073}", "s", "\x{0160}", "\\cap ^s", "\x{0161}", "^s", "\x{0053}\x{030C}", "\\cap ^s", "\x{0073}\x{030C}", "^s", "\x{1E62}", "\\cap .s", "\x{1E63}", ".s", "\x{0053}\x{0323}", "\\cap .s", "\x{0073}\x{0323}", ".s", "\x{1E0C}", "\\cap .d", "\x{1E0D}", ".d", "\x{0044}\x{0323}", "\\cap .d", "\x{0064}\x{0323}", ".d", "\x{1E6C}", "\\cap .t", "\x{1E6D}", ".t", "\x{0054}\x{0323}", "\\cap .t", "\x{0074}\x{0323}", ".t", "\x{1E92}", "\\cap .z", "\x{1E93}", ".z", "\x{005A}\x{0323}", "\\cap .z", "\x{007A}\x{0323}", ".z", "\x{004C}", "\\cap l", "\x{006C}", "l", "\x{004E}", "\\cap n", "\x{006E}", "n", # "\x{0054}", "\\cap T", "\x{0074}", "T", # "\x{004E}", "\\cap N", "\x{006E}", "N", # "\x{0057}", "\\cap W", "\x{0077}", "W", "\x{0041}", "\\cap a", "\x{0061}", "a", "\x{0045}", "\\cap e", "\x{0065}", "e", "\x{0049}", "\\cap i", "\x{0069}", "i", "\x{004F}", "\\cap o", "\x{006F}", "o", "\x{0055}", "\\cap u", "\x{0075}", "u", "\x{0100}", "\\cap A", "\x{0101}", "A", "\x{0041}\x{0304}", "\\cap A", "\x{0061}\x{0304}", "A", "\x{0112}", "\\cap E", "\x{0113}", "E", "\x{0045}\x{0304}", "\\cap E", "\x{0065}\x{0304}", "E", "\x{012A}", "\\cap I", "\x{012B}", "I", "\x{0049}\x{0304}", "\\cap I", "\x{0069}\x{0304}", "I", "\x{014C}", "\\cap O", "\x{014D}", "O", "\x{004F}\x{0304}", "\\cap O", "\x{006F}\x{0304}", "O", "\x{016A}", "\\cap U", "\x{016B}", "U", "\x{0055}\x{0304}", "\\cap U", "\x{0075}\x{0304}", "U", "\x{02BC}", "\"", "\x{02BE}", "'", "\x{02BF}", "`", "\x{0042}", "\\cap b", "\x{0062}", "b", "\x{01E6}", "\\cap ^g", "\x{01E7}", "^g", "\x{0047}\x{030C}", "\\cap ^g", "\x{0067}\x{030C}", "^g", "\x{1E24}", "\\cap .h", "\x{1E25}", ".h", "\x{0048}\x{0323}", "\\cap .h", "\x{0068}\x{0323}", ".h", "\x{1E2A}", "\\cap _h", "\x{1E2B}", "_h", "\x{0048}\x{032E}", "\\cap _h", "\x{0068}\x{032E}", "_h", "\x{0120}", "\\cap .g", "\x{0121}", ".g", "\x{0047}\x{0307}", "\\cap .g", "\x{0067}\x{0307}", ".g", "\x{0046}", "\\cap f", "\x{0066}", "f", "\x{0051}", "\\cap q", "\x{0071}", "q", "\x{004B}", "\\cap k", "\x{006B}", "k", "\x{004D}", "\\cap m", "\x{006D}", "m", "\x{0048}", "\\cap h", "\x{0068}", "h", "\x{0057}", "\\cap w", "\x{0077}", "w", "\x{0059}", "\\cap y", "\x{0079}", "y", "\x{0050}", "\\cap p", "\x{0070}", "p", "\x{0056}", "\\cap v", "\x{0076}", "v", "\x{0047}", "\\cap g", "\x{0067}", "g", "\x{0043}", "\\cap c", "\x{0063}", "c", "\x{010C}", "\\cap ^c", "\x{010D}", "^c", "\x{0043}\x{030C}", "\\cap ^c", "\x{0063}\x{030C}", "^c", "\x{0106}", "\\cap ,c", "\x{0107}", ",c", "\x{0043}\x{0301}", "\\cap ,c", "\x{0063}\x{0301}", ",c", "\x{017D}", "\\cap ^z", "\x{017E}", "^z", "\x{005A}\x{030C}", "\\cap ^z", "\x{007A}\x{030C}", "^z", "\x{00D1}", "\\cap ^n", "\x{00F1}", "^n", "\x{004E}\x{0303}", "\\cap ^n", "\x{006E}\x{0303}", "^n", "\x{004C}\x{0303}", "\\cap ^l", "\x{006C}\x{0303}", "^l", "\x{0052}\x{0307}", "\\cap .r", "\x{0072}\x{0307}", ".r", ); no strict 'refs'; ${ $cls . '::encoder' } = $encoder; if ($option{'describe'}) { $_->describe('') foreach @{${ $cls . '::encoder' }}; } return ${ $cls . '::encoder' }; } sub decoder ($;$$) { my ($cls, undef, undef) = @_; my $decoder = []; my @sunny = ( [ "t", "\x{0074}" ], [ "_t", "\x{0074}\x{0331}" ], # "\x{1E6F}" [ "d", "\x{0064}" ], [ "_d", "\x{0064}\x{0331}" ], # "\x{1E0F}" [ "r", "\x{0072}" ], [ "z", "\x{007A}" ], [ "s", "\x{0073}" ], [ "^s", "\x{0073}\x{030C}" ], # "\x{0161}" [ ".s", "\x{0073}\x{0323}" ], # "\x{1E63}" [ ".d", "\x{0064}\x{0323}" ], # "\x{1E0D}" [ ".t", "\x{0074}\x{0323}" ], # "\x{1E6D}" [ ".z", "\x{007A}\x{0323}" ], # "\x{1E93}" [ "l", "\x{006C}" ], [ "n", "\x{006E}" ], ); my @extra = ( [ "T", "\x{0074}" ], [ "H", "\x{0068}" ], # "" [ "N", "\x{006E}" ], [ "W", "\x{0077}" ], # "" ); my @vowel = ( [ "a", "\x{0061}" ], [ "_a", "\x{0061}\x{0304}" ], # "\x{0101}" [ "_aA", "\x{0061}\x{0304}" ], # "\x{0101}" [ "_aY", "\x{0061}\x{0304}" ], # "\x{0101}" [ "_aU", "\x{0061}\x{0304}" ], # "\x{0101}" [ "_aI", "\x{0061}\x{0304}" ], # "\x{0101}" [ "A", "\x{0061}\x{0304}" ], # "\x{0101}" [ "^A", "\x{0061}\x{0304}" ], # "\x{0101}" [ "_A", "\x{0061}\x{0304}" ], # "\x{0101}" [ "e", "\x{0065}" ], [ "E", "\x{0065}\x{0304}" ], # "\x{0113}" [ "i", "\x{0069}" ], [ "_i", "\x{0069}\x{0304}" ], # "\x{012B}" [ "I", "\x{0069}\x{0304}" ], # "\x{012B}" [ "^I", "\x{0069}\x{0304}" ], # "\x{012B}" [ "_I", "\x{0069}" ], [ "o", "\x{006F}" ], [ "O", "\x{006F}\x{0304}" ], # "\x{014D}" [ "u", "\x{0075}" ], [ "_u", "\x{0075}\x{0304}" ], # "\x{016B}" [ "U", "\x{0075}\x{0304}" ], # "\x{016B}" [ "^U", "\x{0075}\x{0304}" ], # "\x{016B}" [ "_U", "\x{0075}" ], [ "Y", "\x{0061}\x{0304}" ], # "\x{0101}" ); my @minor = ( [ "'", "\x{02BE}" ], # "\x{02BC}" [ "`", "\x{02BF}" ], # "\x{02BB}" ); my @empty = ( [ "\"", "", ], # "\x{02BC}" [ "|", "", ], [ "B", "", ], ); my @moony = ( [ "b", "\x{0062}" ], [ "^g", "\x{0067}\x{030C}" ], # "\x{01E7}" [ ".h", "\x{0068}\x{0323}" ], # "\x{1E25}" [ "_h", "\x{0068}\x{032E}" ], # "\x{1E2B}" [ ".g", "\x{0067}\x{0307}" ], # "\x{0121}" [ "f", "\x{0066}" ], [ "q", "\x{0071}" ], [ "k", "\x{006B}" ], [ "m", "\x{006D}" ], [ "h", "\x{0068}" ], [ "w", "\x{0077}" ], [ "y", "\x{0079}" ], [ "p", "\x{0070}" ], [ "v", "\x{0076}" ], [ "g", "\x{0067}" ], [ "c", "\x{0063}" ], [ "^c", "\x{0063}\x{030C}" ], # "\x{010D}" [ ",c", "\x{0063}\x{0301}" ], # "\x{0107}" [ "^z", "\x{007A}\x{030C}" ], # "\x{017E}" [ "^n", "\x{006E}\x{0303}" ], # "\x{00F1}" [ "^l", "\x{006C}\x{0303}" ], [ ".r", "\x{0072}\x{0307}" ], ); $decoder->[0] = Encode::Mapper->compile ( [ 'silent' => 0, ], # definite article assimilation .. non-linguistic ( map { "l-" . $_->[0] x 2, [ "", $_->[0] . "-" . $_->[0] ], } @sunny, @moony ), # initial vowel tying ( map { my $x = $_; map { my $y = $_; map { $x->[0] . $_ . $y, $x->[1] . $_ . "\x{02BC}", # "\x{02C8}" "\\cap\x09" . $x->[0] . $_ . $y, ucfirst $x->[1] . $_ . "\x{02BC}", # "\x{02C8}" "\\cap\x0A" . $x->[0] . $_ . $y, ucfirst $x->[1] . $_ . "\x{02BC}", # "\x{02C8}" "\\cap\x0D" . $x->[0] . $_ . $y, ucfirst $x->[1] . $_ . "\x{02BC}", # "\x{02C8}" "\\cap\x20" . $x->[0] . $_ . $y, ucfirst $x->[1] . $_ . "\x{02BC}", # "\x{02C8}" } "-", "\x09", "\x0A", "\x0D", "\x20", "\x0D\x0A", "\x20\x20", "\x20\x20\x20", "\x20\x20\x20\x20" } "a", "e", "i", "o", "u" } @vowel ), # silence the silent "_W", "", "WA", [ "", "W" ], "UW", [ "", "U" ], "UA", [ "", "U" ], "NA", [ "", "N" ], "NY", [ "", "N" ], "NU", [ "", "N" ], "N_A", [ "", "N" ], # regular capitalization ( map { $_->[0], $_->[1], "\\cap\x09" . $_->[0], ucfirst $_->[1], "\\cap\x0A" . $_->[0], ucfirst $_->[1], "\\cap\x0D" . $_->[0], ucfirst $_->[1], "\\cap\x20" . $_->[0], ucfirst $_->[1], } @sunny, @moony, @empty, @vowel, @extra ), ( map { $_->[0] . "i", $_->[1] . "i", $_->[0] . "u", $_->[1] . "u", "\\cap\x09" . $_->[0] . "i", ucfirst $_->[1] . "i", "\\cap\x0A" . $_->[0] . "i", ucfirst $_->[1] . "i", "\\cap\x0D" . $_->[0] . "i", ucfirst $_->[1] . "i", "\\cap\x20" . $_->[0] . "i", ucfirst $_->[1] . "i", "\\cap\x09" . $_->[0] . "u", ucfirst $_->[1] . "u", "\\cap\x0A" . $_->[0] . "u", ucfirst $_->[1] . "u", "\\cap\x0D" . $_->[0] . "u", ucfirst $_->[1] . "u", "\\cap\x20" . $_->[0] . "u", ucfirst $_->[1] . "u", } @sunny, @moony, @empty ), ( map { my $x = $_; map { $x->[0] . "i" . $_, [ $x->[1], "i" . $_ ], $x->[0] . "u" . $_, [ $x->[1], "u" . $_ ], "\\cap\x09" . $x->[0] . "i" . $_, [ ucfirst $x->[1], "i" . $_ ], "\\cap\x0A" . $x->[0] . "i" . $_, [ ucfirst $x->[1], "i" . $_ ], "\\cap\x0D" . $x->[0] . "i" . $_, [ ucfirst $x->[1], "i" . $_ ], "\\cap\x20" . $x->[0] . "i" . $_, [ ucfirst $x->[1], "i" . $_ ], "\\cap\x09" . $x->[0] . "u" . $_, [ ucfirst $x->[1], "u" . $_ ], "\\cap\x0A" . $x->[0] . "u" . $_, [ ucfirst $x->[1], "u" . $_ ], "\\cap\x0D" . $x->[0] . "u" . $_, [ ucfirst $x->[1], "u" . $_ ], "\\cap\x20" . $x->[0] . "u" . $_, [ ucfirst $x->[1], "u" . $_ ], } "-", "\x09", "\x0A", "\x0D", "\x20" } @sunny, @moony, @empty ), # initial vowel assimilation ( map { my $fix = $_; "i" . $_, [ "", "I" ], "u" . $_, [ "", "U" ], "\\cap\x09" . "i" . $_, [ "", "\\cap\x09" . "I" ], "\\cap\x0A" . "i" . $_, [ "", "\\cap\x0A" . "I" ], "\\cap\x0D" . "i" . $_, [ "", "\\cap\x0D" . "I" ], "\\cap\x20" . "i" . $_, [ "", "\\cap\x20" . "I" ], "\\cap\x09" . "u" . $_, [ "", "\\cap\x09" . "U" ], "\\cap\x0A" . "u" . $_, [ "", "\\cap\x0A" . "U" ], "\\cap\x0D" . "u" . $_, [ "", "\\cap\x0D" . "U" ], "\\cap\x20" . "u" . $_, [ "", "\\cap\x20" . "U" ], map { "i" . $fix . $_->[0], [ "i", $fix . $_->[0] ], "u" . $fix . $_->[0], [ "u", $fix . $_->[0] ], "\\cap\x09" . "i" . $fix . $_->[0], [ "I", $fix . $_->[0] ], "\\cap\x0A" . "i" . $fix . $_->[0], [ "I", $fix . $_->[0] ], "\\cap\x0D" . "i" . $fix . $_->[0], [ "I", $fix . $_->[0] ], "\\cap\x20" . "i" . $fix . $_->[0], [ "I", $fix . $_->[0] ], "\\cap\x09" . "u" . $fix . $_->[0], [ "U", $fix . $_->[0] ], "\\cap\x0A" . "u" . $fix . $_->[0], [ "U", $fix . $_->[0] ], "\\cap\x0D" . "u" . $fix . $_->[0], [ "U", $fix . $_->[0] ], "\\cap\x20" . "u" . $fix . $_->[0], [ "U", $fix . $_->[0] ], } @vowel, $empty[0] } "y", "w" # "'" ), # capitalization of minors ( map { $_->[0], $_->[1], $_->[0] . "i", $_->[1] . "i", $_->[0] . "u", $_->[1] . "u", "\\cap\x09" . $_->[0], [ $_->[1], "\\cap " ], "\\cap\x0A" . $_->[0], [ $_->[1], "\\cap " ], "\\cap\x0D" . $_->[0], [ $_->[1], "\\cap " ], "\\cap\x20" . $_->[0], [ $_->[1], "\\cap " ], "\\cap\x09" . $_->[0] . "i", $_->[1] . ucfirst "i", "\\cap\x0A" . $_->[0] . "i", $_->[1] . ucfirst "i", "\\cap\x0D" . $_->[0] . "i", $_->[1] . ucfirst "i", "\\cap\x20" . $_->[0] . "i", $_->[1] . ucfirst "i", "\\cap\x09" . $_->[0] . "u", $_->[1] . ucfirst "u", "\\cap\x0A" . $_->[0] . "u", $_->[1] . ucfirst "u", "\\cap\x0D" . $_->[0] . "u", $_->[1] . ucfirst "u", "\\cap\x20" . $_->[0] . "u", $_->[1] . ucfirst "u", } @minor ), ( map { my $x = $_; map { $x->[0] . "i" . $_, [ $x->[1], "i" . $_ ], $x->[0] . "u" . $_, [ $x->[1], "u" . $_ ], "\\cap\x09" . $x->[0] . "i" . $_, [ $x->[1], "\\cap i" . $_ ], "\\cap\x0A" . $x->[0] . "i" . $_, [ $x->[1], "\\cap i" . $_ ], "\\cap\x0D" . $x->[0] . "i" . $_, [ $x->[1], "\\cap i" . $_ ], "\\cap\x20" . $x->[0] . "i" . $_, [ $x->[1], "\\cap i" . $_ ], "\\cap\x09" . $x->[0] . "u" . $_, [ $x->[1], "\\cap u" . $_ ], "\\cap\x0A" . $x->[0] . "u" . $_, [ $x->[1], "\\cap u" . $_ ], "\\cap\x0D" . $x->[0] . "u" . $_, [ $x->[1], "\\cap u" . $_ ], "\\cap\x20" . $x->[0] . "u" . $_, [ $x->[1], "\\cap u" . $_ ], } "-", "\x09", "\x0A", "\x0D", "\x20" } @minor ), # white-space collapsing ( map { "\\cap\x09" . $_, [ "", "\\cap " ], "\\cap\x0A" . $_, [ "", "\\cap " ], "\\cap\x0D" . $_, [ "", "\\cap " ], "\\cap\x20" . $_, [ "", "\\cap " ], } "\x09", "\x0A", "\x0D", "\x20" ), ); no strict 'refs'; ${ $cls . '::decoder' } = $decoder; if ($option{'describe'}) { $_->describe('') foreach @{${ $cls . '::decoder' }}; } return ${ $cls . '::decoder' }; } 1; __END__ =head1 NAME Encode::Arabic::ArabTeX::ZDMG - ZDMG phonetic transcription of Arabic using the ArabTeX notation =head1 SYNOPSIS use Encode::Arabic::ArabTeX::ZDMG; # imports just like 'use Encode' would, plus extended options while ($line = <>) { # maps the ArabTeX notation for Arabic into the Latin symbols print encode 'utf8', decode 'zdmg', $line; # 'ZDMG' alias 'ArabTeX-ZDMG' } # ArabTeX lower ASCII transliteration <--> Latin phonetic transcription, ZDMG style $string = decode 'ArabTeX-ZDMG', $octets; $octets = encode 'ArabTeX-ZDMG', $string; =head1 DESCRIPTION ArabTeX is an excellent extension to TeX/LaTeX designed for typesetting the right-to-left scripts of the Orient. It comes up with very intuitive and comprehensible lower ASCII transliterations, the expressive power of which is even better than that of the scripts. L implements the rules needed for proper interpretation of the ArabTeX notation of Arabic into the phonetic transcription in the ZDMG style. The conversion ifself is done by L, and the user interface is built on the L module. Relevant guidance is given in L, from which this module inherits. The transformation rules are, however, quite different ;) =head1 SEE ALSO L, L, L, L, L ArabTeX system L Klaus Lagally L ArabTeX extensions L ArabXeTeX L Encode Arabic: Exercise in Functional Parsing L =head1 AUTHOR Otakar Smrz C<< >>, L =head1 COPYRIGHT AND LICENSE Copyright (C) 2003-2010 Otakar Smrz This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Encode-Arabic-14.1/lib/Encode/Arabic/ArabTeX/ZDMG000755001750001750 012410623243 21110 5ustar00otakarotakar000000000000Encode-Arabic-14.1/lib/Encode/Arabic/ArabTeX/ZDMG/RE.pm000444001750001750 605712410623243 22121 0ustar00otakarotakar000000000000# ################################################################### Otakar Smrz, 2003/01/23 # # Encoding of Arabic: ArabTeX Notation by Klaus Lagally ##################################### package Encode::Arabic::ArabTeX::ZDMG::RE; our $VERSION = '14.1'; use 5.008; use strict; use warnings; sub import { # perform import as if Encode were used one level before this module require Encode; push @Encode::ISA, 'Exporter' unless Encode->can('export_to_level'); Encode->export_to_level(1, @_); } use Encode::Encoding; use base 'Encode::Encoding'; __PACKAGE__->Define('ZDMG-RE', 'ArabTeX-ZDMG-RE'); our (%encode_used, %decode_used, @shams, @qamar); sub encode ($$;$$) { my (undef, $text, $check, $mode) = @_; $_[1] = '' if $check; # this is what in-place edit needs $text = Encode::encode "utf8", $text if Encode::is_utf8($text); return $text; } sub decode ($$;$) { my (undef, $text, $check) = @_; $_[1] = '' if $check; # this is what in-place edit needs $text = Encode::decode "utf8", $text unless Encode::is_utf8($text); for ($text) { s/NY/n/g; s/UA/u\x{0304}/g; s/WA/w/g; s/_a/a\x{0304}/g; s/N/n/g; s/Y/a\x{0304}/g; s/T/t/g; #s/y/j/g; s/\\cap\s+([\._\^]?)([a-zAIU])/$1\*$2/g; s/\\cap\s+(['`])([a-zAIUEO])/\*$1\*$2/g; s/\.(\*?[hsdtz])/$1\x{0323}/g; s/\.(\*?g)/$1\x{0307}/g; s/_(\*?[td])/$1\x{0331}/g; s/_(\*?)h/$1\x{032E}/g; #s/_(\*?)h/$1ch/g; s/\^(\*?[gs])/$1\x{030C}/g; #s/\^(\*?s)/\\v{$1}/g; #s/\^(\*?)g/$1d\\v{z}/g; s/(? module. Originally, the method helped data typesetting in TeX. It has been modified to produce correct Perl's representation engaging Combining Diacritical Marks from the Unicode Standard, Version 4.0. =head2 EXPORT Exports as if C also appeared in the package. =head1 SEE ALSO L =head1 AUTHOR Otakar Smrz C<< >>, L =head1 COPYRIGHT AND LICENSE Copyright (C) 2003-2012 Otakar Smrz This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Encode-Arabic-14.1/bin000755001750001750 012410623243 14505 5ustar00otakarotakar000000000000Encode-Arabic-14.1/bin/decode.pl000444001750001750 432112410623243 16422 0ustar00otakarotakar000000000000#! perl -w use Encode::Arabic::Buckwalter ':xml'; use Encode::Arabic; our $VERSION = $Encode::Arabic::VERSION; use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1; $options = { 'p' => '', 's' => '' }; getopts('p:s:v', $options); die $Encode::Arabic::VERSION . "\n" if exists $options->{'v'}; $e = shift @ARGV; while (<>) { print encode "utf8", decode $e, $options->{'p'} . $_ . $options->{'s'}; } __END__ =head1 NAME decode - Filter script mimicking the decode function =head1 SYNOPSIS Examples of command-line invocation: $ decode ArabTeX < decode.d | encode Buckwalter > encode.d $ decode MacArabic < data.MacArabic > data.UTF8 $ encode WinArabic < data.UTF8 > data.WinArabic The core of the implementation: getopts('p:s:v', $options); $e = shift @ARGV; while (<>) { print encode "utf8", decode $e, $options->{'p'} . $_ . $options->{'s'}; } =head1 DESCRIPTION The L library provides a unified interface for converting strings from different encodings into a common representation, and vice versa. The L and L programs mimick the fuction calls to the C and C methods, respectively. For the list of supported encoding schemes, please refer to L and the source files of the programs. The naming of encodings is case-insensitive. =head1 OPTIONS decode [OPTIONS] encoding -v --version show program's version --help show usage information -p text --prefix=text prefix input with text -s text --suffix=text suffix input with text =head1 SEE ALSO Encode Arabic Online Interface L Encode Arabic Project L ElixirFM Project L L, L, L =head1 AUTHOR Otakar Smrz C<< >>, L =head1 COPYRIGHT AND LICENSE Copyright (C) 2003-2012 Otakar Smrz This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Encode-Arabic-14.1/bin/encode.pl000444001750001750 432112410623243 16434 0ustar00otakarotakar000000000000#! perl -w use Encode::Arabic::Buckwalter ':xml'; use Encode::Arabic; our $VERSION = $Encode::Arabic::VERSION; use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1; $options = { 'p' => '', 's' => '' }; getopts('p:s:v', $options); die $Encode::Arabic::VERSION . "\n" if exists $options->{'v'}; $e = shift @ARGV; while (<>) { print encode $e, decode "utf8", $options->{'p'} . $_ . $options->{'s'}; } __END__ =head1 NAME encode - Filter script mimicking the encode function =head1 SYNOPSIS Examples of command-line invocation: $ decode ArabTeX < decode.d | encode Buckwalter > encode.d $ decode MacArabic < data.MacArabic > data.UTF8 $ encode WinArabic < data.UTF8 > data.WinArabic The core of the implementation: getopts('p:s:v', $options); $e = shift @ARGV; while (<>) { print encode $e, decode "utf8", $options->{'p'} . $_ . $options->{'s'}; } =head1 DESCRIPTION The L library provides a unified interface for converting strings from different encodings into a common representation, and vice versa. The L and L programs mimick the fuction calls to the C and C methods, respectively. For the list of supported encoding schemes, please refer to L and the source files of the programs. The naming of encodings is case-insensitive. =head1 OPTIONS encode [OPTIONS] encoding -v --version show program's version --help show usage information -p text --prefix=text prefix input with text -s text --suffix=text suffix input with text =head1 SEE ALSO Encode Arabic Online Interface L Encode Arabic Project L ElixirFM Project L L, L, L =head1 AUTHOR Otakar Smrz C<< >>, L =head1 COPYRIGHT AND LICENSE Copyright (C) 2003-2012 Otakar Smrz This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Encode-Arabic-14.1/css000755001750001750 012410623243 14525 5ustar00otakarotakar000000000000Encode-Arabic-14.1/css/encode.css000444001750001750 263012410623243 16632 0ustar00otakarotakar000000000000body { font-family: DejaVu Sans Condensed, DejaVu Sans, Arial Unicode MS, Tahoma, Verdana, Arial, Helvetica, sans-serif; font-weight: normal; font-size: medium; color: black; background-color: white; } td { font-size: medium; font-weight: normal; text-decoration: none; } input { font-size: medium; } h1 { font-size: x-large; font-weight: bold; color: #EEE8AA /*palegoldenrod*/; background-color: #4B0082 /*indigo*/; padding: 3px 6px; } h2 { font-size: large; font-weight: bold; color: #4B0082 /*indigo*/; border: 1px; border-style: solid; border-color: #DAA520 /*goldenrod*/; padding: 2px 5px; } h3 { font-size: medium; font-weight: bold; color: #4B0082 /*indigo*/; background-color: #EEE8AA /*palegoldenrod*/; } p.arabic { direction: rtl; } a:link { color: #4B0082 /*indigo*/; text-decoration: none; } h1 a:link { color: #FFD700 /*gold*/; text-decoration: none; } a:visited { color: #DAA520 /*goldenrod*/; text-decoration: none; } h1 a:visited { color: #FFD700 /*gold*/; text-decoration: none; } a:hover { color: #FFD700 /*gold*/; text-decoration: none; } h1 a:hover { color: #FFD700 /*gold*/; text-decoration: none; } a:active { color: #DAA520 /*goldenrod*/; text-decoration: none; } p.char { font-size: x-small; } p.byte { font-size: x-small; } Encode-Arabic-14.1/css/encode.js000444001750001750 66712410623243 16446 0ustar00otakarotakar000000000000function encodeYamli (n) { var code = document.getElementsByName('decode'); for (var i = 0; i < code.length; i++) { if (code[i].checked) { if (code[i].value == 'Unicode') { Yamli.yamlify('text'); } else { Yamli.deyamlify('text'); } } } var text = document.getElementById('text'); text.focus(); text.select(); }