// Copyright: Matthias Steffens and the file's // original author(s). // // This code is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY. Please see the GNU General Public // License for more details. // // File: ./includes/transtab_unicode_refbase.inc.php // Repository: $HeadURL$ // Author(s): Matthias Steffens // // Created: 11-Jun-08, 13:00 // Modified: $Date: 2008-06-19 17:56:34 +0000 (Thu, 19 Jun 2008) $ // $Author$ // $Revision: 1146 $ // Search & replace patterns and functions for conversion from Unicode entities to refbase markup. // Search & replace patterns must be specified as perl-style regular expression and search patterns must include the leading & trailing slashes. $transtab_unicode_refbase = array( '/‰|‰/' => "[permil]", // ‰: (per mille sign); ‰: ? '/∞/' => "[infinity]", // (infinity) '/α/' => "[alpha]", '/β/' => "[beta]", '/γ/' => "[gamma]", '/δ/' => "[delta]", '/ε/' => "[epsilon]", '/ζ/' => "[zeta]", '/η/' => "[eta]", '/θ/' => "[theta]", '/ι/' => "[iota]", '/κ/' => "[kappa]", '/λ/' => "[lambda]", '/μ/' => "[mu]", '/ν/' => "[nu]", '/ξ/' => "[xi]", '/ο/' => "[omicron]", '/π/' => "[pi]", '/ρ/' => "[rho]", '/ς/' => "[sigmaf]", '/σ/' => "[sigma]", '/τ/' => "[tau]", '/υ/' => "[upsilon]", '/φ/' => "[phi]", '/χ/' => "[chi]", '/ψ/' => "[psi]", '/ω/' => "[omega]", '/Α/' => "[Alpha]", '/Β/' => "[Beta]", '/Γ/' => "[Gamma]", '/Δ/' => "[Delta]", '/Ε/' => "[Epsilon]", '/Ζ/' => "[Zeta]", '/Η/' => "[Eta]", '/Θ/' => "[Theta]", '/Ι/' => "[Iota]", '/Κ/' => "[Kappa]", '/Λ/' => "[Lambda]", '/Μ/' => "[Mu]", '/Ν/' => "[Nu]", '/Ξ/' => "[Xi]", '/Ο/' => "[Omicron]", '/Π/' => "[Pi]", '/Ρ/' => "[Rho]", '/Σ/' => "[Sigma]", '/Τ/' => "[Tau]", '/Υ/' => "[Upsilon]", '/Φ/' => "[Phi]", '/Χ/' => "[Chi]", '/Ψ/' => "[Psi]", '/Ω/' => "[Omega]", "/((?:¹|²|³|⁴|⁵|⁶|⁷|⁸|⁹|⁰|⁺|⁻|⁼|⁽|⁾|ⁿ)+)/ie" => "unicodeSuperScriptToRefbase('\\1')", // function 'unicodeSuperScriptToRefbase()' will convert Unicode superscript entities to appropriate refbase superscript markup "/((?:₁|₂|₃|₄|₅|₆|₇|₈|₉|₀|₊|₋|₌|₍|₎)+)/ie" => "unicodeSubScriptToRefbase('\\1')", // function 'unicodeSubScriptToRefbase()' will convert Unicode subscript entities to appropriate refbase subscript markup // Note that, when matching superscript or subscript Unicode characters, we cannot use the double-byte characters within character classes // (like [¹²³⁴⁵⁶⁷⁸⁹⁰⁺⁻⁼⁽⁾ⁿ] or ([₁₂₃₄₅₆₇₈₉₀₊₋₌₍₎]) since this may cause the single-byte parts of these characters to be matched and replaced as well! ); $unicodeSuperScriptSearchReplaceActionsArray = array( '/¹/' => "1", // (superscript one) '/²/' => "2", // (superscript two) '/³/' => "3", // (superscript three) '/⁴/' => "4", // (superscript four) '/⁵/' => "5", // (superscript five) '/⁶/' => "6", // (superscript six) '/⁷/' => "7", // (superscript seven) '/⁸/' => "8", // (superscript eight) '/⁹/' => "9", // (superscript nine) '/⁰/' => "0", // (superscript zero) '/⁺/' => "+", // (superscript plus sign) '/⁻/' => "-", // (superscript minus) '/⁼/' => "=", // (superscript equals sign) '/⁽/' => "(", // (superscript left parenthesis) '/⁾/' => ")", // (superscript right parenthesis) '/ⁿ/' => "n", // (superscript latin small letter n) ); $unicodeSubScriptSearchReplaceActionsArray = array( '/₁/' => "1", // (subscript one) '/₂/' => "2", // (subscript two) '/₃/' => "3", // (subscript three) '/₄/' => "4", // (subscript four) '/₅/' => "5", // (subscript five) '/₆/' => "6", // (subscript six) '/₇/' => "7", // (subscript seven) '/₈/' => "8", // (subscript eight) '/₉/' => "9", // (subscript nine) '/₀/' => "0", // (subscript zero) '/₊/' => "+", // (subscript plus sign) '/₋/' => "-", // (subscript minus) '/₌/' => "=", // (subscript equals sign) '/₍/' => "(", // (subscript left parenthesis) '/₎/' => ")", // (subscript right parenthesis) ); // -------------------------------------------------------------------- // Converts Unicode superscript entities to appropriate refbase superscript markup: function unicodeSuperScriptToRefbase($sourceString) { global $unicodeSuperScriptSearchReplaceActionsArray; $sourceString = searchReplaceText($unicodeSuperScriptSearchReplaceActionsArray, $sourceString, true); // function 'searchReplaceText()' is defined in 'include.inc.php' return "[super:" . $sourceString . "]"; } // -------------------------------------------------------------------- // Converts Unicode subscript entities to appropriate refbase subscript markup: function unicodeSubScriptToRefbase($sourceString) { global $unicodeSubScriptSearchReplaceActionsArray; $sourceString = searchReplaceText($unicodeSubScriptSearchReplaceActionsArray, $sourceString, true); // function 'searchReplaceText()' is defined in 'include.inc.php' return "[sub:" . $sourceString . "]"; } ?>