From 75cc25c48dc421f11c50f1cb14cc12edeade823f Mon Sep 17 00:00:00 2001
From: Emilian Grecu <emilian.grecu@aut.pub.ro>
Date: Mon, 19 Aug 2019 14:29:19 +0300
Subject: [PATCH] Fix count() issues with PHP7.2 (#104)

---
 application/controllers/AdminController.php   |    4 +-
 .../controllers/ResellerController.php        |   22 +-
 application/views/helpers/FlashMessages.php   |    2 +-
 application/views/helpers/Table.php           |    6 +-
 .../views/scripts/admin/listresellers.phtml   |    2 +-
 application/views/scripts/domain/index.phtml  |    2 +-
 .../views/scripts/reseller/listaccounts.phtml |   10 +-
 .../views/scripts/reseller/listdomains.phtml  |   26 +-
 library/Cpanel/Core/Object.php                |   54 +-
 library/Cpanel/Parser/XML.php                 |   98 +-
 library/Cpanel/PublicAPI.php                  |  113 +-
 library/Cpanel/Query/Object.php               |  126 +-
 library/Cpanel/Service/Abstract.php           |  154 +-
 library/Cpanel/Service/WHM.php                |   50 +-
 library/Cpanel/Service/XmlapiClientClass.php  |  348 +-
 library/Cpanel/Service/cPanel.php             |   68 +-
 library/IDNA/Convert.php                      | 5402 ++++++++---------
 library/SpamFilter/Core.php                   |   23 +-
 library/SpamFilter/Diagnostics.php            |   14 +-
 library/SpamFilter/Hooks.php                  |   13 +-
 library/SpamFilter/PanelSupport/Cpanel.php    |   99 +-
 library/SpamFilter/ResellerAPI/Action.php     |    2 +-
 library/Zend/Json.php                         |   17 +-
 library/functions.php                         |  976 +--
 24 files changed, 3822 insertions(+), 3809 deletions(-)

diff --git a/application/controllers/AdminController.php b/application/controllers/AdminController.php
index 5300cf2d..e676c652 100644
--- a/application/controllers/AdminController.php
+++ b/application/controllers/AdminController.php
@@ -236,7 +236,7 @@ public function brandingAction()
                 $values         = $this->_request->getPost(); // Technically we should use *this*
                 if ($form->isValid($_POST)) {
                     $uploadedData = $form->getValues();
-                    
+
                     if (empty($uploadedData['brandicon'])) {
                         $values['brandicon'] = trim($this->_branding->getBrandIcon());
                         $this->_flashMessenger->addMessage(
@@ -298,7 +298,7 @@ public function listresellersAction()
         }
         $resellers = $this->_panel->getResellers();
 
-        if ((!isset($resellers)) || (empty($resellers)) || (count($resellers) == 0)) {
+        if ((!isset($resellers)) || (empty($resellers)) || (is_array($resellers) && count($resellers) === 0)) {
             $this->_flashMessenger->addMessage(
                 array('message' => $this->t->_('Unable to retrieve resellers.'), 'status' => 'error')
             );
diff --git a/application/controllers/ResellerController.php b/application/controllers/ResellerController.php
index 5a760448..1e4ea13a 100644
--- a/application/controllers/ResellerController.php
+++ b/application/controllers/ResellerController.php
@@ -59,7 +59,7 @@ class ResellerController extends Zend_Controller_Action
      * @var SpamFilter_PanelSupport_Cpanel
      */
 	protected $_panel;
-        
+
 	public function init()
 	{
 		try {
@@ -135,19 +135,19 @@ public function listdomainsAction()
 		$config = Zend_Registry::get('general_config');
 		$this->view->isConfigured = (!empty($config->apiuser)) ? true : false;
 		if(!$this->view->isConfigured) { return false; }
-                
+
                 // Items Per Page functionality
                 $itemsPerPage = $this->_getParam('items')? (int)htmlspecialchars($this->_getParam('items')) : 25 ;
                 if($itemsPerPage<1 || $itemsPerPage > 25){
                     $this->view->itemsPerPageLimit = $this->t->_('The items per page parameter should be an integer greater than or equal to 1 and less than or equal to 25');
                     $itemsPerPage = 25;
                 }
-                       
+
                 // Get params
                 $filter = htmlspecialchars($this->_getParam('search'));
                 $order = $this->_getParam('sortorder');
 		$oldorder = SpamFilter_Panel_Cache::get( 'domains_sort_order' );
-                
+
                 // Get domain from cache if not root
                 if(SpamFilter_Core::getUsername() != 'root'){
                     $domains = SpamFilter_Panel_Cache::get(SpamFilter_Core::getDomainsCacheId());
@@ -162,8 +162,8 @@ public function listdomainsAction()
         if ($order != $oldorder) {
             $domains = $this->_panel->getSortedDomains(array ('domains' => $domains, 'order' => $order));
             SpamFilter_Panel_Cache::set(SpamFilter_Core::getDomainsCacheId(), $domains);
-		}              
-                
+		}
+
 		// No cache set, proceed with retrieval
 		if (empty($domains)) {
 		    $domains = $this->_panel->getDomains(
@@ -177,7 +177,7 @@ public function listdomainsAction()
             // Cache miss, save the data
 			SpamFilter_Panel_Cache::set(SpamFilter_Core::getDomainsCacheId(), $domains);
 		}
-                
+
 		// Proceed
 		if ( !isset($domains))
 		{
@@ -190,7 +190,7 @@ public function listdomainsAction()
 			return false;
 		}
 
-		if ((empty($domains)) || (count($domains) == 0) )
+		if ((empty($domains)) || (is_countable($domains) && count($domains) === 0) )
 		{
 			$this->_flashMessenger->addMessage(
 							array(
@@ -200,11 +200,11 @@ public function listdomainsAction()
 							);
 			return false;
 		}
-                
+
                 if(!empty($filter)){
                     $domains = $this->_panel->filterDomains(array('domains' => $domains, 'filter' => $filter));
                 }
-                if ((empty($domains)) || (count($domains) == 0) )
+                if ((empty($domains)) || (is_countable($domains) && count($domains) == 0) )
 		{
 			$this->_flashMessenger->addMessage(
 							array(
@@ -257,7 +257,7 @@ public function listaccountsAction()
 		}
 
 		// Proceed
-		if( (!isset($accounts)) || (empty($accounts)) || (count($accounts) == 0) )
+		if( (!isset($accounts)) || (empty($accounts)) || (is_countable($accounts) && count($accounts) == 0) )
 		{
 			$this->_flashMessenger->addMessage(
 							array(
diff --git a/application/views/helpers/FlashMessages.php b/application/views/helpers/FlashMessages.php
index faa38aa4..089255a0 100644
--- a/application/views/helpers/FlashMessages.php
+++ b/application/views/helpers/FlashMessages.php
@@ -48,7 +48,7 @@ public function flashMessages($translator = NULL)
 		$output = '';
 
 		// If there are no messages, don't bother with this whole process.
-		if (count($messages) > 0)
+		if (is_array($messages) && count($messages) > 0)
 		{
 			// This chunk of code takes the messages (formatted as in the above sample
 			// input) and puts them into an array of the form:
diff --git a/application/views/helpers/Table.php b/application/views/helpers/Table.php
index 49b16c76..782afec5 100644
--- a/application/views/helpers/Table.php
+++ b/application/views/helpers/Table.php
@@ -112,7 +112,7 @@ public function setColumns(array $columns)
 
     /**
      * Set table summary
-     * 
+     *
      * @param string $summary
      * @return App_View_Helper_Table
      */
@@ -172,7 +172,7 @@ public function addRow($cols)
      */
     public function setRows($rows)
     {
-        if (count($rows)) {
+        if (is_countable($rows) && count($rows)) {
             foreach ($rows as $r) {
                 $this->addRow($r);
             }
@@ -279,7 +279,7 @@ public function toString()
                     elseif (isset($r[$i])) {
                         $xhtml .= stripslashes($r[$i]);
                     }
-                    
+
 
                     $xhtml .= '</td>';
                     $i++;
diff --git a/application/views/scripts/admin/listresellers.phtml b/application/views/scripts/admin/listresellers.phtml
index 7761ff7c..25616840 100644
--- a/application/views/scripts/admin/listresellers.phtml
+++ b/application/views/scripts/admin/listresellers.phtml
@@ -11,7 +11,7 @@
     </thead>
     <tbody>
         <?php
-        if (count($this->paginator) == 0) {
+        if ($this->paginator->count() == 0) {
             echo '<tr><td colspan="2">' . $this->t->_('There are no resellers in the system.') . '</td></tr>';
         }
 
diff --git a/application/views/scripts/domain/index.phtml b/application/views/scripts/domain/index.phtml
index bbc596cf..7c7a3c06 100755
--- a/application/views/scripts/domain/index.phtml
+++ b/application/views/scripts/domain/index.phtml
@@ -43,7 +43,7 @@ if (!$this->hasAPIAccess) {
     </thead>
     <tbody>
         <?php
-        if (count($this->paginator) == 0) {
+        if ($this->paginator->count() === 0) {
             echo '<tr><td colspan="3">' . $this->t->_('There are no domains assigned to your account') . '</td></tr>';
         }
 
diff --git a/application/views/scripts/reseller/listaccounts.phtml b/application/views/scripts/reseller/listaccounts.phtml
index 46171ad2..0467c4fb 100644
--- a/application/views/scripts/reseller/listaccounts.phtml
+++ b/application/views/scripts/reseller/listaccounts.phtml
@@ -16,16 +16,16 @@ if( !$this->isConfigured )
 			<th><?php echo $this->t->_('Username'); ?></th>
 			<th><?php echo $this->t->_('Primary domain'); ?></th>
 			<th></th>
-		</tr>	
+		</tr>
 	</thead>
 	<tbody>
-<?php 
-	if( count($this->paginator) == 0 )
+<?php
+	if( $this->paginator->count() === 0 )
 	{
 		echo '<tr><td colspan="3">' . $this->t->_('There are no users assigned to your account') . '</td></tr>';
 	}
 
-	foreach( $this->paginator as $u ) 
+	foreach( $this->paginator as $u )
 	{
 	?>
 		<tr>
@@ -33,7 +33,7 @@ if( !$this->isConfigured )
 			<td><?php echo $u['domain']; ?></td>
 			<td><a href="?q=reseller/toggleuser/user/<?php echo $u['user']; ?>/state/enable"><?php echo $this->t->_('Enable Protection'); ?></a> | <a href="?q=reseller/toggleuser/user/<?php echo $u['user']; ?>/state/disable"><?php echo $this->t->_('Disable Protection'); ?></a></td>
 		</tr>
-	<?php 
+	<?php
 	}
 	?>
 	</tbody>
diff --git a/application/views/scripts/reseller/listdomains.phtml b/application/views/scripts/reseller/listdomains.phtml
index 4e136877..aa167fc7 100644
--- a/application/views/scripts/reseller/listdomains.phtml
+++ b/application/views/scripts/reseller/listdomains.phtml
@@ -43,9 +43,9 @@ if( !$this->isConfigured )
                 parentDocumentTitle = window.top.document.title;
                 if (parentDocumentTitle.indexOf(brandname) == -1) {
                     window.top.document.title = parentDocumentTitle + ' - ' +  brandname;
-                } 
+                }
             } catch(e) {
-        
+
             }
         });
     </script>
@@ -82,7 +82,7 @@ if( !$this->isConfigured )
         </thead>
         <tbody>
         <?php
-        if( count($this->paginator) == 0 )
+        if( $this->paginator->count() === 0 )
         {
 		echo '<tr><td colspan="5">'. $this->t->_('No content to display') . '</td></tr>';
         }
@@ -246,11 +246,11 @@ if( !$this->isConfigured )
                 window.location = goTo;
                 return false;
             });
-            
+
             $("#changeItems").click(function(event){
                 event.preventDefault();
                 changeItemsPerPage();
-            });            
+            });
 
             $("#toggleSelected").click(function(event) {
                 event.preventDefault();
@@ -264,7 +264,7 @@ if( !$this->isConfigured )
                 return false;
             });
 
-        
+
             $("#sortDomain").click(function() {
                 var pattern = /\b\/sortorder\/[^/]*/g;
                 var matches = pattern.exec(window.location.href);
@@ -342,7 +342,7 @@ if( !$this->isConfigured )
             if(items < 1 || items > 25){
                 $("#itemsPerPageInfo").html('The items per page parameter should be an integer greater than or equal to 1 and less than or equal to 25');
                 $("#itemsPerPageInfo").show(0);
-                $("html, body").animate({ scrollTop: 0 }, "slow");           
+                $("html, body").animate({ scrollTop: 0 }, "slow");
                 return false;
             }
             var pattern = /\b\/items\/[^/]*/g;
@@ -350,19 +350,19 @@ if( !$this->isConfigured )
             var goTo;
             if(matches){
                 goTo = window.location.href.replace(matches[0], "/items/"+ items);
-            } else {                       
-                goTo = prepareURI() + '/items/' + items;                              
-            }  
+            } else {
+                goTo = prepareURI() + '/items/' + items;
+            }
             window.location = goTo;
             return false;
         };
-        
+
         function toggleProtection(thisObj){
             thisObj.hide(0);
             thisObj.before(loading_html);
             protectionRequest(thisObj);
         }
-        
+
         function prepareURI(){
             var s = window.location.href;
             var pattern = /\?q=reseller\/listdomains/g;
@@ -388,7 +388,7 @@ if( !$this->isConfigured )
                 protectionRequest(selected[i]);
             }
         }
-    
+
         function disableButtons(){
             $('#sortDomain').addClass("disabled");
             $('.tableButtons').find('button').each(function() {
diff --git a/library/Cpanel/Core/Object.php b/library/Cpanel/Core/Object.php
index c13a47bf..63972b1c 100755
--- a/library/Cpanel/Core/Object.php
+++ b/library/Cpanel/Core/Object.php
@@ -1,7 +1,7 @@
 <?php
 /**
  * Cpanel_Core_Object
- * 
+ *
  * Copyright (c) 2011, cPanel, Inc.
  * All rights reserved.
  * http://cpanel.net
@@ -27,19 +27,19 @@
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ *
  * @category  Cpanel
  * @package   Cpanel_Core
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
  */
 /**
  * Base class for any Cpanel class to inherit from.
- * 
+ *
  * This class is a container class with accessors to the internal storage.  The
  * internal stoeage container will store data as a Cpanel_Core_Object
  * such that it the parent object can continuely recure into the data structure.
@@ -48,8 +48,8 @@
  * @category  Cpanel
  * @package   Cpanel_Core
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
@@ -62,10 +62,10 @@ class Cpanel_Core_Object implements IteratorAggregate
     protected $dataContainer;
     /**
      * Constructor
-     * 
+     *
      * @param array $optsArray Data to store internally
-     * 
-     * @return void 
+     *
+     * @return void
      */
     public function __construct($optsArray = array())
     {
@@ -76,7 +76,7 @@ public function __construct($optsArray = array())
     }
     /**
      * IteratorAggregate required method
-     * 
+     *
      * @return ArrayIterator Internal data with an iterable object
      */
     public function getIterator()
@@ -85,10 +85,10 @@ public function getIterator()
     }
     /**
      * Accessor for storing data internally
-     * 
+     *
      * @param array $optsArray Array of key/value parses to store internally
      * @param bool  $override  Override any previous stored data. Default is true
-     * 
+     *
      * @return Cpanel_Core_Object
      */
     public function setOptions($optsArray, $override = true)
@@ -104,7 +104,7 @@ public function setOptions($optsArray, $override = true)
                 .'"parent::__construct()"'
             );
         }
-        if (count($optsArray) == 0) {
+        if (is_countable($optsArray) && count($optsArray) === 0) {
             return $this;
         } elseif (is_array($optsArray)) {
             foreach ($optsArray as $key => $value) {
@@ -138,15 +138,15 @@ public function setOptions($optsArray, $override = true)
             //}elseif(is_object($optsArray)){ //not supported ATM
             //some fallback to get_object_vars or
             // implement an iterable if
-            
+
         }
         return $this;
     }
     /**
      * Accessor method for retrieving internal data
-     * 
+     *
      * @param string $key Key to search for within data store
-     * 
+     *
      * @return mixed|void Value if $key exists, otherwise NULL
      */
     public function getOption($key)
@@ -158,7 +158,7 @@ public function getOption($key)
     }
     /**
      * Retrieve internal data storage object
-     * 
+     *
      * @return ArrayObject
      */
     public function getAllData()
@@ -167,7 +167,7 @@ public function getAllData()
     }
     /**
      * Retreive a deeply nested array structure representation of data store
-     * 
+     *
      * @return array Array representation of internal data object storage
      */
     public function getAllDataRecursively()
@@ -186,11 +186,11 @@ public function getAllDataRecursively()
     }
     /**
      * Magic get accessor
-     * 
+     *
      * @param string $key Key to search for in internal data storage
-     * 
+     *
      * @see    getOption()
-     * 
+     *
      * @return mixed|void Value of $key if it exists, otherwise null
      */
     public function __get($key)
@@ -199,13 +199,13 @@ public function __get($key)
     }
     /**
      * Magic set accessor
-     * 
+     *
      * @param string $key   Key portion of element to store
      * @param mixed  $value Value portion of element to store
-     * 
+     *
      * @see    setOptions()
-     * 
-     * @return void  
+     *
+     * @return void
      */
     public function __set($key, $value)
     {
@@ -216,4 +216,4 @@ public function __set($key, $value)
         );
     }
 }
-?>
\ No newline at end of file
+?>
diff --git a/library/Cpanel/Parser/XML.php b/library/Cpanel/Parser/XML.php
index ae6d1563..ae330814 100755
--- a/library/Cpanel/Parser/XML.php
+++ b/library/Cpanel/Parser/XML.php
@@ -1,7 +1,7 @@
 <?php
 /**
  * Cpanel_Parser_XML
- * 
+ *
  * Copyright (c) 2011, cPanel, Inc.
  * All rights reserved.
  * http://cpanel.net
@@ -27,12 +27,12 @@
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ *
  * @category  Cpanel
  * @package   Cpanel_Parser
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
@@ -44,8 +44,8 @@
  * @category  Cpanel
  * @package   Cpanel_Parser
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
@@ -90,13 +90,13 @@ class Cpanel_Parser_XML extends Cpanel_Core_Object implements Cpanel_Parser_Inte
     private $_hasParseError;
     /**
      * Constructor
-     * 
+     *
      * By default, Cpanel_Parser_XML::DOM_MODE will be set.  As well,
      * all errors warnings generated by LibXML will be suppressed.  This errors
      * well be collected later, in the event of a decode error.
-     * 
+     *
      * @param arrays $optsArray Optional configuration data
-     * 
+     *
      * @return Cpanel_Parser_XML
      */
     public function __construct($optsArray = array())
@@ -113,11 +113,11 @@ public function __construct($optsArray = array())
     }
     /**
      * Determine if an RFT can be parsed with this parser
-     * 
+     *
      * @param string $type The name of a response format type to evaluate
-     * 
+     *
      * @see    Cpanel_Parser_Interface::canParse()
-     * 
+     *
      * @return bool   Whether this parser can parse a sting of $type
      */
     public function canParse($type)
@@ -126,22 +126,22 @@ public function canParse($type)
     }
     /**
      * Parse a string into an array structure
-     * 
+     *
      * By default, Cpanel_Parser_XML::DOM_MODE will be used to decode
      * $str.  Alternative decode modes can be set prior to parsing via
      * {@link setMode()}
-     * 
+     *
      * NOTE: After basic validation, if the parser cannot successfully parse
      * $str, internal property "_hasParseError" will be set to true.  An error
      * will NOT be throw.  This is to ensure a premature exit does not occur
      * since the query (likely) succeeded.  Problem as this level are ambiguous,
      * and therefore left to the invoking script/application to manage.
-     * 
+     *
      * @param string $str String to parse
-     * 
+     *
      * @see    Cpanel_Parser_XML::getParserInternalErrors
      * @see    Cpanel_Parser_Interface::parse()
-     * 
+     *
      * @return array|string Array representation of string on success,
      *                      otherwise a string expressing error.
      * @throws Exception If $str is not a string
@@ -175,15 +175,15 @@ public function parse($str)
     }
     /**
      * Encode array structure into this parser's format type
-     * 
+     *
      * Encoding is only performed with DOMDocument.  Returned XML string will
      * be formated with line breaking and whitespace characters.
-     * 
+     *
      * @param Cpanel_Query_Object $obj Response object containing data to
      *  encode
-     * 
+     *
      * @see    Cpanel_Parser_Interface::encodeQueryObject()
-     * 
+     *
      * @return string              XML document
      * @throws Exception If $obj is an invalid response object
      */
@@ -197,11 +197,11 @@ public function encodeQueryObject($obj)
         $this->_dom->preserveWhiteSpace = false;
         $this->_dom->formatOutput = true;
         // TODO: add error detection for empty arr
-        if (count($arr) > 1) {
+        if (is_array($arr) && count($arr) > 1) {
             $root = $this->_dom->createElement('result');
             $this->_dom->appendChild($root);
             $this->_recurse_node_build($arr, $root);
-        } elseif (count($arr) == 1) {
+        } elseif (is_array($arr) && count($arr) === 1) {
             $this->_recurse_node_build($arr, $this->_dom);
         }
         $r = $this->_dom->saveXML();
@@ -210,15 +210,15 @@ public function encodeQueryObject($obj)
     }
     /**
      * Recursive build DOMDocument from array
-     * 
+     *
      * NOTE: because objects are passed by reference, $obj will not be returned
-     * 
+     *
      * Credit to Matt Wiseman (trollboy at shoggoth.net) for recursion schema
-     * 
+     *
      * @param array                  $data Array to convert to DOMElements
      * @param DOMDocument|DOMElement $obj  DOMDocument|DOMElement to append to
-     * 
-     * @return void                  
+     *
+     * @return void
      */
     private function _recurse_node_build($data, $obj)
     {
@@ -252,9 +252,9 @@ private function _recurse_node_build($data, $obj)
     }
     /**
      * Import XML string into new DOMDocument
-     * 
+     *
      * @param string $str XML string to import
-     * 
+     *
      * @return DOMDocument
      */
     protected function strToDOM($str)
@@ -270,10 +270,10 @@ protected function strToDOM($str)
     }
     /**
      * Convert DOMDocument into PHP array, recursing as necessary
-     * 
+     *
      * @param DOMDocument|DOMElement $node DOMDocument|DOMElement to recurse
-     * 
-     * @return array                  PHP array representation of $node 
+     *
+     * @return array                  PHP array representation of $node
      */
     protected function DOMtoArray($node)
     {
@@ -309,9 +309,9 @@ protected function DOMtoArray($node)
     }
     /**
      * Import XML string into new SimpleXML object
-     * 
+     *
      * @param string $str XML string to import
-     * 
+     *
      * @return SimpleXMLElement
      */
     protected function strToSimpleXML($str)
@@ -327,11 +327,11 @@ protected function strToSimpleXML($str)
     }
     /**
      * Convert SimpleXMLElement into PHP array, recursing as necessary
-     * 
+     *
      * @param SimpleXMLEement $input   SimpleXMLElement to recurse
      * @param bool            $recurse Whether this invocation is recursive
-     * 
-     * @return array           PHP array representation of $input 
+     *
+     * @return array           PHP array representation of $input
      */
     protected function simpleXMLToArray($input, $recurse = false)
     {
@@ -354,17 +354,17 @@ protected function simpleXMLToArray($input, $recurse = false)
     }
     /**
      * Generate an error string to bubble up
-     * 
+     *
      * If LibXML errors have previously been suppress, libxml_get_errors() will
      * be invoked to fetch them.
-     * 
-     * @param string $prefix  A string to prefix the returned error string for 
+     *
+     * @param string $prefix  A string to prefix the returned error string for
      *  contextual reference
-     * @param string $default A default error message if one can not be 
+     * @param string $default A default error message if one can not be
      *  determined (from the native PHP LibXML error functions)
-     * 
+     *
      * @see    Cpanel_Parser_Interface::getParserInternalErrors()
-     * 
+     *
      * @return string String detailing an error has occurred
      */
     public function getParserInternalErrors($prefix = '', $default = 'Could not load string.')
@@ -391,7 +391,7 @@ public function getParserInternalErrors($prefix = '', $default = 'Could not load
     }
     /**
      * Set special encode mode
-     * 
+     *
      * This parser supports use of DOM or SimpleXML.  This primarily only has
      * importance when iterating over interpreted response. i.e., in the legacy
      * XML-API PHP client class, when a (SimpleXML) object was returned, the
@@ -399,13 +399,13 @@ public function getParserInternalErrors($prefix = '', $default = 'Could not load
      * introduction of Cpanel_Parser_XML::DOM_MODE_EXTENDED it is
      * possible to iterate at the document's root element itself.  i.e
      * ( $obj->firstchild vs. $obj->rootnode->childnode)
-     * 
+     *
      * @param int $flag Constant value to set encoding mode to
-     * 
+     *
      * @see    Cpanel_Parser_XML::DOM_MODE
      * @see    Cpanel_Parser_XML::DOM_MODE_EXTENDED
      * @see    Cpanel_Parser_XML::SIMPLEXML_MODE
-     * 
+     *
      * @return Cpanel_Parser_XML
      */
     public function setMode($flag)
@@ -420,4 +420,4 @@ public function setMode($flag)
         return $this;
     }
 }
-?>
\ No newline at end of file
+?>
diff --git a/library/Cpanel/PublicAPI.php b/library/Cpanel/PublicAPI.php
index 957bbe15..0d122138 100755
--- a/library/Cpanel/PublicAPI.php
+++ b/library/Cpanel/PublicAPI.php
@@ -1,7 +1,7 @@
 <?php
 /**
  * Cpanel_PublicAPI
- * 
+ *
  * Copyright (c) 2011, cPanel, Inc.
  * All rights reserved.
  * http://cpanel.net
@@ -27,30 +27,30 @@
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ *
  * @category  Cpanel
  * @package   Cpanel_PublicAPI
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
  */
 /**
  * PublicAPI client class.
- * 
+ *
  * The PublicAPI client class provides a PHP class for the PublicAPI interface,
  * which is used by other API client classes in other languages, but this client
  * also incorporates the legacy cPanel PHP client classes, namely LivePHP and
- * XML-API. 
+ * XML-API.
  *
  * @class     Cpanel_PublicAPI
  * @category  Cpanel
  * @package   Cpanel_PublicAPI
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
@@ -79,10 +79,10 @@ class Cpanel_PublicAPI extends Cpanel_Core_Object
     /**
      * The class is a Singleton.  The constructor, however is public due to
      * inheritance from Cpanel_Core_Object.
-     * 
+     *
      * @param arrays $optsArray Option configuration data
-     * 
-     * @return Cpanel_PublicAPI  
+     *
+     * @return Cpanel_PublicAPI
      * @throws Exception If      instantiated directly. {@link getInstance()}
      */
     public function __construct($optsArray = false)
@@ -122,8 +122,8 @@ public function __construct($optsArray = false)
     }
     /**
      * Enforce singleton; no cloning; php >=5.0
-     * 
-     * @return void     
+     *
+     * @return void
      * @throws Exception If class is cloned.
      */
     final public function __clone()
@@ -132,9 +132,9 @@ final public function __clone()
     }
     /**
      * Get the Singleton instance, creating it as necessary.
-     * 
+     *
      * @param array $optsArray Optional configuration data
-     * 
+     *
      * @return Cpanel_PublicAPI
      */
     public static function getInstance($optsArray = array())
@@ -148,10 +148,10 @@ public static function getInstance($optsArray = array())
     }
     /**
      * Obliterate all internals
-     * 
+     *
      * Useful for enforcing a known state. It is extremely rare, outside of unit
      * testing, that this method is used.
-     * 
+     *
      * @return void
      */
     public static function resetInstance()
@@ -162,14 +162,14 @@ public static function resetInstance()
     }
     /**
      * Create the internal registry for storing factory objects.
-     * 
+     *
      * NOTE: Any class outside the PHP builtin space or the Cpanel package space
      * will need to have been previously included/required or be available via
-     * previously defined autoloader.  The class specificed should be or 
+     * previously defined autoloader.  The class specificed should be or
      * inherit from ArrayObject.
      *
-     * @param string $registryClass Name of object class to instantiate 
-     * 
+     * @param string $registryClass Name of object class to instantiate
+     *
      * @return Cpanel_PublicAPI
      * @throws Exception If $registryClass does not inherit ArrayObject
      */
@@ -197,7 +197,7 @@ protected function registerRegistry($registryClass = '')
     }
     /**
      * Return internal factory object registry.
-     * 
+     *
      * @return ArrayObject|mixed
      */
     protected function getRegistry()
@@ -206,17 +206,17 @@ protected function getRegistry()
     }
     /**
      * Retrieve the Service namespace from given array or config, if one exists
-     * 
+     *
      * If the Cpanel config convention is utilized, a successful return will
      * provide a Cpanel_Core_Object which should have a key/namespace
-     * 'config'. If the $type is not found, the general service namespace will 
+     * 'config'. If the $type is not found, the general service namespace will
      * be returned (which may also have the 'config' namespace).
-     * 
+     *
      * @param string             $type      The named service type to retrieve
      * @param Cpanel_Core_Object $optsArray Cpanel config to search within
-     * 
+     *
      * @return Cpanel_Core_Object|array Emtpy array if $type or $optsArray is
-     *  empty, otherwise the expected configuration data 
+     *  empty, otherwise the expected configuration data
      */
     public static function getServiceConfig($type, $optsArray)
     {
@@ -251,11 +251,11 @@ public static function getServiceConfig($type, $optsArray)
     }
     /**
      * Used to extract config values from a specific namespace
-     * 
+     *
      * @param string             $name      Namespace to seek config values for
      * @param Cpanel_Core_Object $optsArray Config to seek within
-     * 
-     * @return Cpanel_Core_Object|array Empty array if $optsArray is 
+     *
+     * @return Cpanel_Core_Object|array Empty array if $optsArray is
      *  empty or $name do not exist if config.
      */
     public static function getNamedConfig($name, $optsArray)
@@ -279,12 +279,12 @@ public static function getNamedConfig($name, $optsArray)
     }
     /**
      * Recursively merge two arrays.
-     * 
-     * @param array $arr1 base array, existing key/values will be overwritten 
+     *
+     * @param array $arr1 base array, existing key/values will be overwritten
      * @param array $arr2 array of new values
-     * 
+     *
      * @static
-     * 
+     *
      * @return array A new array contain all values of the two arrays, keys in
      *  second array take precedent
      */
@@ -301,11 +301,11 @@ public static function mergeConfigs($arr1, $arr2)
     }
     /**
      * Return an aggregated config based on passed config & stored config values
-     * 
+     *
      * @param string $type      Service type
      * @param arrays $optsArray Additional config to parse/merge
      * @param string $name      Specific namespace to seek
-     * 
+     *
      * @return array Aggregated config
      */
     private static function _getAggregateConfig($type, $optsArray, $name)
@@ -316,8 +316,8 @@ private static function _getAggregateConfig($type, $optsArray, $name)
         //TODO: decouple and thoroughly test deeply nested configs
         if (!empty($name)) {
             $workingConfigNamed = $self->getNamedConfig($name, $workingConfig);
-            if (count($workingConfigNamed)) {
-                if (count($workingConfig->config)) {
+            if (is_countable($workingConfig) && count($workingConfigNamed)) {
+                if (is_countable($workingConfig->config) && count($workingConfig->config)) {
                     //must try to merge
                     $workingConfig = self::mergeConfigs(
                         $workingConfig->config->getAllDataRecursively(),
@@ -329,6 +329,7 @@ private static function _getAggregateConfig($type, $optsArray, $name)
             }
             $storedNamedConfig = $self->getNamedConfig($name, $storedServicesConfig);
             if ($storedServicesConfig instanceof Cpanel_Core_Object
+                && is_countable($storedServicesConfig->config)
                 && count($storedServicesConfig->config)
             ) {
                 $storedConfig = self::mergeConfigs(
@@ -344,7 +345,7 @@ private static function _getAggregateConfig($type, $optsArray, $name)
             if ($storedServicesConfig instanceof Cpanel_Core_Object
                 && $storedServicesConfig->config
             ) {
-                if (count($storedServicesConfig) > 1) {
+                if (is_countable($storedServicesConfig) && count($storedServicesConfig) > 1) {
                     $default = $storedServicesConfig->getAllDataRecursively();
                     unset($default['config']);
                     $storedConfig = self::mergeConfigs(
@@ -370,7 +371,7 @@ private static function _getAggregateConfig($type, $optsArray, $name)
      * @param array  $optsArray Service  object configuration data
      * @param string $name      Specific name for retrieving a predefine service
      *  setup or stored instance thereof
-     * 
+     *
      * @return mixed      A Cpanel_Service object
      * @throws Exception If invalid service type is requested.
      */
@@ -394,7 +395,7 @@ public static function factory($type, $optsArray = array(), $name = '')
         ) {
             return $self->getRegistry()->offsetGet($type . $tmpName);
         }
-        
+
         // No valid object found: determine class name and instantiate
         $classname;
         $storageName;
@@ -414,13 +415,13 @@ public static function factory($type, $optsArray = array(), $name = '')
             $classname = 'Cpanel_Service_cPanel';
             break;
             // TODO: custom service loading
-            
+
         }
-    
+
         if (!isset($classname) || !class_exists($classname)) {
             throw new Exception("Invalid service: {$type}");
         }
-        
+
         // by change, the same service may be stored under the normalized name
         if (($reg !== null && isset($storageName))
             && (is_string($tmpName))
@@ -429,8 +430,8 @@ public static function factory($type, $optsArray = array(), $name = '')
         ) {
             return $self->getRegistry()->offsetGet($storageName . $tmpName);
         }
-        
-        
+
+
         if (empty($optsArray)) {
             $optsArray = array();
         }
@@ -440,7 +441,7 @@ public static function factory($type, $optsArray = array(), $name = '')
             $optsArray['listner'] = $self->listner;
         }
         $aggConfig = self::_getAggregateConfig($type, $optsArray, $name);
-        
+
         $newobj = new $classname($aggConfig);
         // if registry, store
         if ($reg !== null) {
@@ -453,7 +454,7 @@ public static function factory($type, $optsArray = array(), $name = '')
     }
     /**
      * Direct http URL query
-     * 
+     *
      * @param string $service  cPanel service to use
      * @param string $uri      URI to fetch
      * @param string $method   HTTP method
@@ -461,7 +462,7 @@ public static function factory($type, $optsArray = array(), $name = '')
      *  form data to send
      * @param array  $headers  Associative array of custom header to add to http
      *  request
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     public function api_request($service, $uri, $method = 'GET', $formdata = '', $headers = '')
@@ -478,14 +479,14 @@ public function api_request($service, $uri, $method = 'GET', $formdata = '', $he
     }
     /**
      * Works as dispatch
-     * 
-     * Coordinates with the {@link factory()} to return and instance when 
+     *
+     * Coordinates with the {@link factory()} to return and instance when
      * "get{$service}" is invoked.  Otherwise will take the "api" query method
      * and pass in to an appropriate service object.
      *
      * @param string $method Method name as originally invoked
      * @param array  $args   Method arguments from original call
-     * 
+     *
      * @return Cpanel_Query_Object
      * @throws Exception If service cannot be deduced from "api" query or
      *  original method call was not a "get" or "api" based invocation.
@@ -495,21 +496,21 @@ public function __call($method, $args)
         if (strpos($method, 'get') === 0) {
             //attempt to factory an item
             $type = substr($method, 3);
-            $factargs = (count($args) >= 1 && is_array($args[0])) ? $args[0] : array();
+            $factargs = (is_array($args) && count($args) >= 1 && is_array($args[0])) ? $args[0] : array();
             $name = (is_array($factargs) && array_key_exists('name', $factargs)) ? $factargs['name'] : '';
             return self::factory($type, $factargs, $name);
         } elseif (strpos($method, '_api') !== false) {
             //invoking the service, ie "whm_api", "cpanel_api1_request", etc.
             $type = substr($method, 0, strpos($method, '_'));
             $obj = self::factory($type);
-            if (empty($args) || (is_array($args) && count($args) == 0)) {
+            if (empty($args) || (is_array($args) && count($args) === 0)) {
                 throw new Exception(
                     'Service API call requires at least one parameter'
                 );
             }
             if ($type == 'whm') {
                 $func = $args[0];
-                if (is_array($args) && count($args) == 1) {
+                if (is_array($args) && count($args) === 1) {
                     $args_to_pass = array();
                 } else {
                     $args_to_pass = $args[1];
@@ -531,4 +532,4 @@ public function __call($method, $args)
         throw new Exception("Invalid method: {$method}");
     }
 }
-?>
\ No newline at end of file
+?>
diff --git a/library/Cpanel/Query/Object.php b/library/Cpanel/Query/Object.php
index 44925884..c0b2df3c 100755
--- a/library/Cpanel/Query/Object.php
+++ b/library/Cpanel/Query/Object.php
@@ -1,7 +1,7 @@
 <?php
 /**
  * Cpanel_Query_Object
- * 
+ *
  * Copyright (c) 2011, cPanel, Inc.
  * All rights reserved.
  * http://cpanel.net
@@ -27,25 +27,25 @@
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ *
  * @category  Cpanel
  * @package   Cpanel_Query
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
  */
 /**
  * Query and response object class
- * 
+ *
  * This class works as both a request (or query) and response object in the
  * since of most PHP frameworks. There are two containers for these
  * responsibilities (query and response). Internally they are '_query' and
- * '_response' but can be accessed externally simply by fetching 
+ * '_response' but can be accessed externally simply by fetching
  * $rObj->getQuery() or $rObj->getResponse().  Alternatively, there's a shortcut
- * for fetching individual key/value pairs within those containers.  If 
+ * for fetching individual key/value pairs within those containers.  If
  * $rObj->key is called, $key will be fetched out of the response container. If
  * $rObj->query->key is called, $key will be fetched from the query container.
  * Setting values works in the same manner.
@@ -54,8 +54,8 @@
  * @category  Cpanel
  * @package   Cpanel_Query
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
@@ -112,9 +112,9 @@ class Cpanel_Query_Object extends Cpanel_Core_Object
     const ERROR_PARSE = 'Could not parse.';
     /**
      * Constructor
-     * 
+     *
      * @param arrays $optsArray Optional configuration data
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     public function __construct($optsArray = array())
@@ -130,9 +130,9 @@ public function __construct($optsArray = array())
     }
     /**
      * Set server expected input format
-     * 
+     *
      * @param string $type Input format type
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     public function setInputFormatType($type)
@@ -142,7 +142,7 @@ public function setInputFormatType($type)
     }
     /**
      * Retrieve input format type
-     * 
+     *
      * @return string Input format type
      */
     public function getInputFormatType()
@@ -151,15 +151,15 @@ public function getInputFormatType()
     }
     /**
      * Set response format type
-     * 
+     *
      * The response format type (RFT) is the format of the server response. This
      * value is propagated to the stored parser object (generating a new parser
      * object if one was not previous instantiated)
-     * 
+     *
      * @param string $type   Response format type
      * @param bool   $reinit Force a new parser object instantiation prior to
      *  setting RFT
-     * 
+     *
      * @return Cpanel_Query_Object
      * @throws Exception If parser object does not implement the defined parser
      *  interface
@@ -184,15 +184,15 @@ public function setResponseFormatType($type, $reinit = false)
     }
     /**
      * Instantiate a parser object.
-     * 
+     *
      * This method expects $type to coorelate to a Cpanel parser class located
      * within Cpanel_Library.  If a Cpane parser class cannot be found, $type
      * will be treated as a custom class that has previously been defined (or
      * available via the autoload stack).  Custom parser classes must implement
      * Cpanel_Parser_Interface
-     * 
+     *
      * @param string $type Name of parser to instantiate
-     * 
+     *
      * @return mixed     Parser object which implements Cpanel_Parser_Interface
      * @throws Exception If $type cannot be tranlated to a valid classname for
      *                   instantiation
@@ -226,9 +226,9 @@ public function getValidParser($type)
     }
     /**
      * Store a parser object
-     * 
+     *
      * @param object $obj Parser object that implements Cpanel_Parser_Interface
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     public function setResponseParser($obj)
@@ -243,7 +243,7 @@ public function setResponseParser($obj)
     }
     /**
      * Retrieve the stored parser object
-     * 
+     *
      * @return mixed Object that implements Cpanel_Parser_Interface
      */
     public function getResponseParser()
@@ -252,7 +252,7 @@ public function getResponseParser()
     }
     /**
      * Retrieve the response format type defined in this object
-     * 
+     *
      * @return string
      */
     public function getResponseFormatType()
@@ -261,9 +261,9 @@ public function getResponseFormatType()
     }
     /**
      * Set oupt format for this object
-     * 
+     *
      * @param string $type Output format type
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     public function setOutputFormatType($type)
@@ -273,7 +273,7 @@ public function setOutputFormatType($type)
     }
     /**
      * Retrieve this object's output format type
-     * 
+     *
      * @return string Output format type
      */
     public function getOutputFormatType()
@@ -282,15 +282,15 @@ public function getOutputFormatType()
     }
     /**
      * Retrieve a representation of the server response as requested by $type
-     * 
+     *
      * The method, by default will return the response container, a
      * Cpanel_CpanelObject which is an iterable object.  Other options include:
      * 'array'  - An deeply nested array representation of the server response
      * "$type"  - Where $type is an RFT for which a parser can be instantiated,
      *   i.e. 'JSON' or 'XML', etc.
-     * 
+     *
      * @param string $type Response format type to return
-     * 
+     *
      * @return mixed  String, array, or object as requested by $type
      */
     public function getResponse($type = '')
@@ -311,16 +311,16 @@ public function getResponse($type = '')
     }
     /**
      * Store error in internal error stack
-     * 
+     *
      * @param string|array $err Error message string or array of such strings
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     protected function setResponseError($err)
     {
         if (is_string($err)) {
             array_push($this->_responseErrors, $err);
-        } elseif (count($err)) {
+        } elseif (is_array($err) && count($err)) {
             foreach ($err as $e) {
                 array_push($this->_responseErrors, $e);
             }
@@ -329,7 +329,7 @@ protected function setResponseError($err)
     }
     /**
      * Check if parser object reported errors
-     * 
+     *
      * @return bool Whether the parser object was able to parser server response
      */
     public function validResponse()
@@ -341,9 +341,9 @@ public function validResponse()
     }
     /**
      * Retrieve all error reported by parser
-     *  
+     *
      * @param bool $flush Flush internal error stack.  Default is FALSE.
-     * 
+     *
      * @return array|void An array of error string, otherwise null if no errors
      *                    were reported by the parser object
      */
@@ -361,9 +361,9 @@ public function getResponseErrors($flush = false)
     }
     /**
      * Set multiple key/value pairs in the query container
-     * 
+     *
      * @param array $obj An array of key/value pairs to set
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     public function setQuery($obj)
@@ -373,7 +373,7 @@ public function setQuery($obj)
     }
     /**
      * Retrieve the query container
-     * 
+     *
      * @return Cpanel_Core_Object
      */
     public function getQuery()
@@ -382,17 +382,17 @@ public function getQuery()
     }
     /**
      * Parse and store a raw response
-     * 
+     *
      * This method is responsible for receiving a raw server response, storing
      * it, passing the raw response to the parser object and finally storing
      * the parse response.  If parsing errors occur, the value of the response
-     * contain will be empty and errors can be collected via 
+     * contain will be empty and errors can be collected via
      * {@link getResponseErrors()}
-     * 
+     *
      * @param string $raw The raw response string from the server
-     * 
+     *
      * @see    getResponseErrors()
-     * 
+     *
      * @return Cpanel_Core_Object
      */
     public function parse($raw)
@@ -409,7 +409,7 @@ public function parse($raw)
                         self::ERROR_RESPONSE . self::ERROR_PARSE
                     );
                     //@codeCoverageIgnoreEnd
-                    
+
                 } elseif (is_string($parsedResponse)) {
                     $this->setResponseError(
                         self::ERROR_RESPONSE . $parsedResponse
@@ -423,7 +423,7 @@ public function parse($raw)
     }
     /**
      * Trigger parser object's parse() against server's raw response
-     * 
+     *
      * @return array|string Array representation of raw response, otherwise a
      *                      string denoting error observed by parser
      * @throws Exception If parser object does not implement
@@ -440,9 +440,9 @@ private function _parseWithParser()
     }
     /**
      * Store key/value pairs in response container
-     * 
+     *
      * @param array $obj Array of key/value pairs to set
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     public function setResponse($obj)
@@ -452,7 +452,7 @@ public function setResponse($obj)
     }
     /**
      * Retrieve raw server response
-     * 
+     *
      * @return string Raw server response string
      */
     public function getRawResponse()
@@ -461,9 +461,9 @@ public function getRawResponse()
     }
     /**
      * Store raw server response
-     * 
+     *
      * @param string $str String to store as the raw server response
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     public function setRawResponse($str = null)
@@ -477,13 +477,13 @@ public function setRawResponse($str = null)
     }
     /**
      * Magic get accessor
-     * 
-     * If $key is 'query', the query container is returned.  This allows for 
+     *
+     * If $key is 'query', the query container is returned.  This allows for
      * effective chain calls like $rObj->query->ulitamteKeyDesired in calling
      * scripts.  Otherwise, $key will source from the response container
-     * 
+     *
      * @param string $key Key to search for
-     * 
+     *
      * @return mixed  Value sourced for $key within the response container, or
      *  the query container if $key is 'query'
      */
@@ -497,15 +497,15 @@ public function __get($key)
     }
     /**
      * Magic set accessor
-     * 
+     *
      * The method will store key/value pairs within the response container. If
      * storage to the query contain is desired, use {@link setQuery()} or a
      * combination of magic {@__get()} methods, i.e. $rObj->query->key = value
-     * 
+     *
      * @param string $key   Key for storage
      * @param mixed  $value Value to associate with $key
-     * 
-     * @return void  
+     *
+     * @return void
      */
     public function __set($key, $value)
     {
@@ -517,11 +517,11 @@ public function __set($key, $value)
     }
     /**
      * Magic toString method
-     * 
-     * This method will return a formatted representation of the response 
+     *
+     * This method will return a formatted representation of the response
      * container (i.e. a print_r style string) when this object is referenced as
      * or cased to a string
-     * 
+     *
      * @return string String representation of the response container object
      */
     public function __toString()
@@ -530,4 +530,4 @@ public function __toString()
         return $str;
     }
 }
-?>
\ No newline at end of file
+?>
diff --git a/library/Cpanel/Service/Abstract.php b/library/Cpanel/Service/Abstract.php
index b30781a7..d546d412 100755
--- a/library/Cpanel/Service/Abstract.php
+++ b/library/Cpanel/Service/Abstract.php
@@ -1,7 +1,7 @@
 <?php
 /**
  * Cpanel_Service_Abstract
- * 
+ *
  * Copyright (c) 2011, cPanel, Inc.
  * All rights reserved.
  * http://cpanel.net
@@ -27,25 +27,25 @@
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ *
  * @category  Cpanel
  * @package   Cpanel_Service
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
 */
 /**
  * Abstract class for Service classes.
- * 
+ *
  * @class     Cpanel_Service_Abstract
  * @category  Cpanel
  * @package   Cpanel_Service
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
@@ -63,11 +63,11 @@ abstract class Cpanel_Service_Abstract extends Cpanel_Core_Object
      */
     protected $disabledAdapters = array();
     /**
-     * Type of array that API1 calls must adhere to 
+     * Type of array that API1 calls must adhere to
      */
     const API1ARGS = 'ordinal';
     /**
-     * Type of array that API2 calls must adhere to 
+     * Type of array that API2 calls must adhere to
      */
     const API2ARGS = 'associative';
     /**
@@ -84,9 +84,9 @@ abstract class Cpanel_Service_Abstract extends Cpanel_Core_Object
     const ADAPTER_LIVE = 'live';
     /**
      * Constructor
-     * 
+     *
      * @param array $optsArray Option configuration data
-     * 
+     *
      * @return Cpanel_Service_Abstract
      */
     public function __construct($optsArray = array())
@@ -103,19 +103,19 @@ public function __construct($optsArray = array())
     }
     /**
      * For use by extending classes to retreive their default adapter name value
-     * 
-     * The method is specifically here to get around late static binding, which 
+     *
+     * The method is specifically here to get around late static binding, which
      * is only available in 5.3
-     * 
+     *
      * @return string
      */
     abstract public function getDefaultAdapterName();
     /**
      * Mark a particular adapter as disabled so that it cannot be explicitly or
      * implicitly used by the Service object instance
-     * 
+     *
      * @param string $type Adapter name to disable
-     * 
+     *
      * @return Cpanel_Service_Abstract
      * @throws Exception If $type is invalid
      */
@@ -132,9 +132,9 @@ public function disableAdapter($type)
     }
     /**
      * Enable a previously disabled adapter with the Service object instance
-     * 
+     *
      * @param string $type Adapter name to enable
-     * 
+     *
      * @return Cpanel_Service_Abstract
      * @throws Exception If $type is invalid
      */
@@ -153,13 +153,13 @@ public function enableAdapter($type)
     }
     /**
      * Initialize key parameters of a RemoteQuery based adpater
-     * 
+     *
      * This will attempt to set host, user, and authentication information, as
-     * well as port and protocol. User and authentication information may 
+     * well as port and protocol. User and authentication information may
      * retrieved from the environment context if that feature is enabled.
-     * 
+     *
      * @param Cpanel_Query_Http_Abstract $adapter Adapter to initialize
-     * 
+     *
      * @return Cpanel_Query_Http_Abstract Initialized adapter
      */
     protected function initAdapter(Cpanel_Query_Http_Abstract $adapter)
@@ -190,7 +190,7 @@ protected function initAdapter(Cpanel_Query_Http_Abstract $adapter)
     /**
      * Fills an array, as necessary, with key/values pairs associated with the
      * initialization process based on the processes effective user.
-     * 
+     *
      * Will set the following key/value pairs if the input array has an empty or
      * undefined pair:
      * host => 127.0.0.1
@@ -198,13 +198,13 @@ protected function initAdapter(Cpanel_Query_Http_Abstract $adapter)
      * password => The password located in the script's environment (not $_ENV),
      *  if available
      * hash => Stored access hash value, if available
-     * 
-     * NOTE: because of the way {@link _getEUIDAuth} works, either hash or 
+     *
+     * NOTE: because of the way {@link _getEUIDAuth} works, either hash or
      * password or neither will be assigned a value
-     *  
+     *
      * @param array $vars The know initialization variables
-     * 
-     * @return array The complete, environment aware state of initialization 
+     *
+     * @return array The complete, environment aware state of initialization
      *               variables
      */
     private function _getEnvironmentContext($vars = array())
@@ -243,14 +243,14 @@ private function _getEnvironmentContext($vars = array())
     }
     /**
      * Fetch either hash or password for the effective user.
-     * 
+     *
      * Hash will be sourced from .accesshash in the user's home directory
      * Password will be sourced from the script's environment (not $_ENV) if
      *  it is visable and the script was spawned from cpsrvd.
-     *  
+     *
      * The returned array will have a 'hash' and 'password' key.  Either hash or
      * password or neither will have a value, but never both.
-     * 
+     *
      * @return array An array containing authentication information
      */
     private function _getEUIDAuth()
@@ -290,7 +290,7 @@ private function _getEUIDAuth()
     }
     /**
      * Simple check to see if the script is a LivePHP script, spawned by cpsrvd
-     * 
+     *
      * @return bool
      */
     public function isLocalQuery()
@@ -304,40 +304,40 @@ public function isLocalQuery()
     /**
      * For use by extending classes to determine if an adapter type is valid for
      * the Service object instance, and if so, to normalize the name.
-     * 
-     * Implementing classes can use this to force the use of a particular 
+     *
+     * Implementing classes can use this to force the use of a particular
      * adapter as necessary. For example, if the script is being executed for
      * a local query, it might be advantage to force the use of a
-     * Cpanel_Abstract_LocalQuery based adapter, despite a request for a 
+     * Cpanel_Abstract_LocalQuery based adapter, despite a request for a
      * Cpanel_Abstract_RemoteQuery.
-     * 
-     * Implementing classes should return a string of the normalized name to 
+     *
+     * Implementing classes should return a string of the normalized name to
      * be used for adapter spawning and demarcation.  If the $type is invalid
      * the method should return false.
-     * 
+     *
      * @param string $type Adapter name to validate and, potentially, normalize
-     * 
+     *
      * @return string|bool normalized name or false if invalid for Service
      */
     abstract protected function validAdapter($type);
     /**
      * Stores the adapter name with a Cpanel_Query_Object
-     * 
-     * If $adapterName is not passed, {@link getDefaultAdapterName()} will 
+     *
+     * If $adapterName is not passed, {@link getDefaultAdapterName()} will
      * populate it.  If passed, {@link validAdapter()} will be called with that
      * as is input argument.
-     * 
-     * NOTE: if {@link isLocalQuery} returns true and a Live adapter has not 
+     *
+     * NOTE: if {@link isLocalQuery} returns true and a Live adapter has not
      * been computed as the adapter type and the Live adapter is not disabled,
      * the method will "optimize" by setting the adapter to a Live type and mark
      * such in the Cpanel_Query_Objects.
-     * 
+     *
      * @param Cpanel_Query_Object $rObj        Response object to update
      * @param string              $adapterName Adapter name to pin to $rObj
-     * 
+     *
      * @todo Consider implementing this only as the concrete service class level
      *       or make more robust concerning optimization
-     *         
+     *
      * @return Cpanel_Query_Object
      */
     protected function updateResponseObjectAdapter(Cpanel_Query_Object $rObj, $adapterName = '')
@@ -361,10 +361,10 @@ protected function updateResponseObjectAdapter(Cpanel_Query_Object $rObj, $adapt
     }
     /**
      * Generate a Cpanel_Query_Object for the Service object instance
-     * 
+     *
      * @param string $adapterName Optional adapterName to pin to the generated
      *                                          resposne object
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     public function genResponseObject($adapterName = '')
@@ -374,16 +374,16 @@ public function genResponseObject($adapterName = '')
     }
     /**
      * Retrieve or spawn an adapter from a given response object
-     * 
+     *
      * This is the primary method for retrieve the adapter for a query call.  It
      * first looks as the response object to see if an adapter name has been
-     * previously determine; if necessary pinning one 
-     * {@link updateResponseObjectAdpater()}.  Second it looks for the named 
+     * previously determine; if necessary pinning one
+     * {@link updateResponseObjectAdpater()}.  Second it looks for the named
      * adapter in storage; if not found it spawns one {@link spawnAdapter()} and
      * stores it. Lastly the adapter is returned
-     * 
+     *
      * @param Cpanel_Query_Object $rObj Response object
-     * 
+     *
      * @return mixed               An adapter for making queries
      * @throws Exception If pinned adapter in response object has been disabled
      */
@@ -407,32 +407,32 @@ public function getAdapter(Cpanel_Query_Object $rObj)
     /**
      * For use by extending classes to generate an appropriate adapter object
      * based on name.
-     * 
+     *
      * @param string $adapterType Name of adapter to spawn.
-     * 
+     *
      * @see    Cpanel_Service_Abstract::getAdapter()
-     * 
+     *
      * @return mixed  An adapter for making queries
      */
     abstract protected function spawnAdapter($adapterType);
     /**
      * Validate query arguments for given service adapter name
-     * 
+     *
      * @param string $service A service adapter name to validate against
      * @param array  $mf      Array representing key parameters for the query call
      * @param array  $args    Array of arguments for the query call
      * @param string $method  Name of method invoking the method (for error msg)
      * @param string $argType Array type to valid $args against
-     * 
+     *
      * @return bool      True if all validation passes
      * @throws Exception If $service is not defined
      * @throws Exception If $mf is not defined
      * @throws Exception If $service is an invalid service adapter name
-     * @throws Exception If $service is Live and script is not local 
+     * @throws Exception If $service is Live and script is not local
      *                   {@link isLocalQuery()}
      * @throws Exception If whostmgr and $mf doesn't define module, function and
      *                   user
-     * @throws Exception If cpanel and $mf doesn't define module, function 
+     * @throws Exception If cpanel and $mf doesn't define module, function
      * @throws Exception If $args array is not observed to be of the same
      *                   type of array indicated by $argType
      */
@@ -464,7 +464,7 @@ protected function checkParams($service, $mf, $args, $method, $argType)
                 ),
                 array_keys($mf)
             );
-            if (count($matchedKeys) != 3) {
+            if (count($matchedKeys) !== 3) {
                 throw new Exception(
                     "{$method} requires both 'module','function', and 'user' "
                     . "be defined in module-function array"
@@ -478,7 +478,7 @@ protected function checkParams($service, $mf, $args, $method, $argType)
                 ),
                 array_keys($mf)
             );
-            if (count($matchedKeys) != 2) {
+            if (count($matchedKeys) !== 2) {
                 throw new Exception(
                     "{$method} requires both 'module' and 'function' "
                     . "be defined in module-function array"
@@ -500,9 +500,9 @@ protected function checkParams($service, $mf, $args, $method, $argType)
     /**
      * Utility method for determining the array type (oridinal or asssociative)
      * of a given array
-     * 
+     *
      * @param array $arr Array to analysis
-     * 
+     *
      * @return string    Determine array type for given array
      * @throws Exception If $arr is not an array or is empty
      */
@@ -525,16 +525,16 @@ protected function arrayType($arr)
     /**
       * Legacy support for scripts that set the desired PHP structure for a given
       * query via a "set_output" method.
-      * 
+      *
       * This will only set the response format type for the generic adapter.
       * More sophisticated Service objects should have their calling scripts use
       * a more appropriate set of methods (available in the Service and Response
       * objects) and not this legacy support method.
-      * 
+      *
      * NOTE: This may be deprecated in future releases
-     * 
+     *
      * @param string $type Response format type desired from server.
-     * 
+     *
      * @return Cpanel_Service_Abstract
      */
     public function set_output($type)
@@ -551,9 +551,9 @@ public function set_output($type)
     }
     /**
      * Proxy accessor method for pushing user into adapters
-     * 
+     *
      * @param string $user Value to set
-     * 
+     *
      * @return Cpanel_Service_Abstract
      */
     public function setUser($user)
@@ -568,9 +568,9 @@ public function setUser($user)
     }
     /**
      * Proxy accessor method for pushing password into adapters
-     * 
+     *
      * @param string $password Value to set
-     * 
+     *
      * @return Cpanel_Service_Abstract
      */
     public function setPassword($password)
@@ -585,9 +585,9 @@ public function setPassword($password)
     }
     /**
      * Proxy accessor method for pushing host into adapters
-     * 
+     *
      * @param string $host Value to set
-     * 
+     *
      * @return Cpanel_Service_Abstract
      */
     public function setHost($host)
@@ -602,9 +602,9 @@ public function setHost($host)
     }
     /**
      * Proxy accessor method for pushing hash into adapters
-     * 
+     *
      * @param string $hash Value to set
-     * 
+     *
      * @return Cpanel_Service_Abstract
      */
     public function setHash($hash)
@@ -618,4 +618,4 @@ public function setHash($hash)
         return $this;
     }
 }
-?>
\ No newline at end of file
+?>
diff --git a/library/Cpanel/Service/WHM.php b/library/Cpanel/Service/WHM.php
index 82a815e5..bda6e8bc 100755
--- a/library/Cpanel/Service/WHM.php
+++ b/library/Cpanel/Service/WHM.php
@@ -1,7 +1,7 @@
 <?php
 /**
  * Cpanel_Service_WHM
- * 
+ *
  * Copyright (c) 2011, cPanel, Inc.
  * All rights reserved.
  * http://cpanel.net
@@ -27,19 +27,19 @@
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ *
  * @category  Cpanel
  * @package   Cpanel_Service
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
  */
-/** 
+/**
  * Whostmgr Service class
- * 
+ *
  * This class can be used by Cpanel_PublicAPI, another custom client, or as a
  * replacement to the legacy XML-API client class.
  *
@@ -47,8 +47,8 @@
  * @category  Cpanel
  * @package   Cpanel_Service
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
@@ -61,14 +61,14 @@ class Cpanel_Service_WHM extends Cpanel_Service_Abstract
     const ADAPTER_DEFAULT = 'whostmgr';
     /**
      * Constructor
-     * 
+     *
      * @param arrays $optsArray Option configuration data
-     * 
+     *
      * @return Cpanel_Service_WHM
      */
     public function __construct($optsArray = array())
     {
-        if (!count($optsArray)) {
+        if (!is_array($optsArray) || !count($optsArray)) {
             $opts = array();
         }
         if (array_key_exists('config', $optsArray)) {
@@ -87,9 +87,9 @@ public function __construct($optsArray = array())
     }
     /**
      * Fetch default adapter name for WHM service
-     * 
+     *
      * @see    Cpanel_Service_Abstract::getDefaultAdapterName()
-     * 
+     *
      * @return string
      */
     public function getDefaultAdapterName()
@@ -98,13 +98,13 @@ public function getDefaultAdapterName()
     }
     /**
      * Validate a given string corresponds to a usable adapter type
-     * 
+     *
      * NOTE: will normalize $type for use in other methods
-     * 
+     *
      * @param string $type service adapter name to validate
-     * 
+     *
      * @see    Cpanel_Service_Abstract::validAdapter()
-     * 
+     *
      * @return string|bool String of normalized $type, if valid, otherwise false
      */
     public function validAdapter($type)
@@ -120,11 +120,11 @@ public function validAdapter($type)
     }
     /**
      * Spawn a new adapter object based on valid service adapter name
-     * 
+     *
      * @param string $adapterType Valid service adapter name
-     * 
+     *
      * @see    Cpanel_Service_Abstract::spawnAdapter()
-     * 
+     *
      * @return Cpanel_Service_Adapter_WHMapi
      */
     protected function spawnAdapter($adapterType)
@@ -143,11 +143,11 @@ protected function spawnAdapter($adapterType)
     }
     /**
      * Direct URL query method for PublicAPI client
-     * 
+     *
      * @param string $uri          URL to query
      * @param array  $formdata     Array of URL parameters
      * @param array  $queryOptions Array of options for query mechanism
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     public function directURLQuery($uri, $formdata, $queryOptions = array())
@@ -171,13 +171,13 @@ public function directURLQuery($uri, $formdata, $queryOptions = array())
     /**
      * Get the current adapter, spawn if necessary, and call requested method on
      * it.
-     * 
+     *
      * NOTE: It's assumed that the adapter implements it's own measure to throw
      * if the method is undefined
      *
      * @param string $method Method to invoke on adapter
      * @param array  $args   Method arguments
-     * 
+     *
      * @return mixed   The result of the success adapter method call
      */
     public function __call($method, $args)
@@ -195,4 +195,4 @@ public function __call($method, $args)
         );
     }
 }
-?>
\ No newline at end of file
+?>
diff --git a/library/Cpanel/Service/XmlapiClientClass.php b/library/Cpanel/Service/XmlapiClientClass.php
index 17b02076..0b7d3e90 100755
--- a/library/Cpanel/Service/XmlapiClientClass.php
+++ b/library/Cpanel/Service/XmlapiClientClass.php
@@ -1,7 +1,7 @@
 <?php
 /**
  * Cpanel_Service_XmlapiClientClass
- * 
+ *
  * Copyright (c) 2011, cPanel, Inc.
  * All rights reserved.
  * http://cpanel.net
@@ -27,19 +27,19 @@
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ *
  * @category  Cpanel
  * @package   Cpanel_Service
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
  */
 /**
  * Abstraction of the PHP XML-API client class
- * 
+ *
  * This class provides an abstraction layer for WHM and cPanel services adapters
  * such that they can support all query-based functions of the legacy XML-API
  * client class.
@@ -49,8 +49,8 @@
  * @package   Cpanel_Service
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
  * @author    Matt Dees <matt@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
@@ -59,45 +59,45 @@ abstract class Cpanel_Service_XmlapiClientClass extends Cpanel_Query_Http_Abstra
 {
     /**
      * Method for querying API1 via XML-API
-     * 
+     *
      * @param string $user     User to query against
      * @param string $module   API1 module to source
      * @param string $function API1 function of $module to invoke
      * @param array  $args     Arguments for $function
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     abstract public function api1_query($user, $module, $function, $args = array());
     /**
      * Method for querying API2 via XML-API
-     * 
+     *
      * @param string $user     User to query against
      * @param string $module   API2 module to source
      * @param string $function API2 function of $module to invoke
      * @param array  $args     Arguments for $function
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     abstract public function api2_query($user, $module, $function, $args = array());
     /**
      * Method for querying a native XML-API function
-     * 
+     *
      * @param string $function XML-API function to invoke
      * @param array  $args     Arguments for $function
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     abstract public function xmlapi_query($function, $args = array());
     //###
     //  XML API Functions
     //###
-    
+
     /**
     * Return a list of available XML-API calls
     *
     * This function will return an array containing all applications available within the XML-API
     *
-    * 
+    *
     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ListAvailableCalls XML API Call documentation
     */
@@ -108,21 +108,21 @@ public function applist()
     //###
     // Account functions
     //###
-    
+
     /**
     * Create a cPanel Account
     *
-    * This function will allow one to create an account, the $acctconf parameter requires that the follow 
+    * This function will allow one to create an account, the $acctconf parameter requires that the follow
     * three associations are defined:
     *   - username
     *   - password
     *   - domain
     *
-    * Failure to prive these will cause an error to be logged.  Any other key/value pairs as defined by the createaccount call 
+    * Failure to prive these will cause an error to be logged.  Any other key/value pairs as defined by the createaccount call
     * documentation are allowed parameters for this call.
-    * 
+    *
     * @param array $acctconf
-    * 
+    *
     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/CreateAccount XML API Call documentation
     */
@@ -131,14 +131,14 @@ public function applist()
      * Insert description here
      *
      * @param $acctconf
-     *                    
-     * 
+     *
+     *
      * @return
-     *         
+     *
      * @access
      * @static
-     * @see   
-     * @since 
+     * @see
+     * @since
      */
     public function createacct($acctconf)
     {
@@ -152,13 +152,13 @@ public function createacct($acctconf)
     }
     /**
     * Change a cPanel Account's Password
-    * 
+    *
     * This function will allow you to change the password of a cpanel account
     *
     * @param string $username The username to change the password of
     * @param string $pass     The new password for the cPanel Account
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ChangePassword XML API Call documentation
     */
     public function passwd($username, $pass)
@@ -178,8 +178,8 @@ public function passwd($username, $pass)
     *
     * @param string $username The username of the cPanel account to modify
     * @param int    $bwlimit  The new bandwidth limit in megabytes
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/LimitBandwidth XML API Call documentation
     */
     public function limitbw($username, $bwlimit)
@@ -199,8 +199,8 @@ public function limitbw($username, $bwlimit)
     *
     * @param string $searchtype Type of account search to use, allowed values: domain, owner, user, ip or package
     * @param string $search     the string to search against
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ListAccounts XML API Call documentation
     */
     public function listaccts($searchtype = null, $search = null)
@@ -221,9 +221,9 @@ public function listaccts($searchtype = null, $search = null)
     *
     * @param string $username The username to modify
     * @param array  $args     the new values for the modified account (see {@link http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ModifyAccount modifyacct documentation})
-    * 
-     * @return mixed 
-    * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ModifyAccount XML API Call documentation 
+    *
+     * @return mixed
+    * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ModifyAccount XML API Call documentation
     */
     public function modifyacct($username, $args = array())
     {
@@ -231,7 +231,7 @@ public function modifyacct($username, $args = array())
             throw new Exception("modifyacct requires that username is passed to it");
         }
         $args['user'] = $username;
-        if (sizeof($args) < 2) {
+        if (!is_array($args) || sizeof($args) < 2) {
             throw new Exception("modifyacct requires that at least one attribute is passed to it");
         }
         return $this->makeQuery('modifyacct', $args);
@@ -243,8 +243,8 @@ public function modifyacct($username, $args = array())
     *
     * @param string $username The username of the account to modify the quota.
     * @param int    $quota    the new quota in megabytes
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/EditQuota XML API Call documentation
     */
     public function editquota($username, $quota)
@@ -271,8 +271,8 @@ public function editquota($username, $quota)
     * Please see the XML API Call documentation for more information on what is returned by this call
     *
     * @param string $username The username to retrieve a summary of
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ShowAccountInformation XML API Call documenation
     */
     public function accountsummary($username)
@@ -292,8 +292,8 @@ public function accountsummary($username)
     *
     * @param string $username The username to suspend
     * @param string $reason   The reason for the suspension
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/SuspendAccount XML API Call documentation
     */
     public function suspendacct($username, $reason = null)
@@ -316,7 +316,7 @@ public function suspendacct($username, $reason = null)
     *
     * This function will return an array containing all the suspended accounts on a server
     *
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ListSuspended XML API Call documentation
     */
@@ -332,8 +332,8 @@ public function listsuspended()
     *
     * @param string $username The usename to delete
     * @param bool   $keepdns  When pass a true value, the DNS zone will be retained
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/TerminateAccount
     */
     public function removeacct($username, $keepdns = false)
@@ -357,8 +357,8 @@ public function removeacct($username, $keepdns = false)
     * This XML API call will unsuspend an account
     *
     * @param string $username The username to unsuspend
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/UnsuspendAcount XML API Call documentation
     */
     public function unsuspendacct($username)
@@ -377,8 +377,8 @@ public function unsuspendacct($username)
     *
     * @param string $username the username to change the package of
     * @param string $pkg      The package to change the account to.
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ChangePackage XML API Call documentation
     */
     public function changepackage($username, $pkg)
@@ -395,7 +395,7 @@ public function changepackage($username, $pkg)
     * Return the privileges a reseller has in WHM
     *
     * This will return a list of the privileges that a reseller has to WHM
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ViewPrivileges XML API Call documentation
     */
@@ -405,12 +405,12 @@ public function myprivs()
     }
     /**
     * Display Data about a Virtual Host
-    * 
+    *
     * This function will return information about a specific domain.  This data is essentially a representation of the data
     * Contained in the httpd.conf VirtualHost for the domain.
     *
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @param string $domain The domain to fetch information for
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/DomainUserData
     */
@@ -419,14 +419,14 @@ public function myprivs()
      * Insert description here
      *
      * @param $domain
-     *                  
-     * 
+     *
+     *
      * @return
-     *         
+     *
      * @access
      * @static
-     * @see   
-     * @since 
+     * @see
+     * @since
      */
     public function domainuserdata($domain)
     {
@@ -439,14 +439,14 @@ public function domainuserdata($domain)
     }
     /**
     * Change a site's IP Address
-    * 
+    *
     * This function will allow you to change the IP address that a domain listens on.
     * In order to properly call this function Either $user or $domain parameters must be defined
     * @param string $ip     The $ip address to change the account or domain to
     * @param string $user   The username to change the IP of
     * @param string $domain The domain to change the IP of
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/SetSiteIp XML API Call documentation
     */
     public function setsiteip($ip, $user = null, $domain = null)
@@ -473,7 +473,7 @@ public function setsiteip($ip, $user = null, $domain = null)
     // DNS Functions
     //###
     // This API function lets you create a DNS zone.
-    
+
     /**
     * Add a DNS Zone
     *
@@ -482,8 +482,8 @@ public function setsiteip($ip, $user = null, $domain = null)
     *
     * @param string $domain The DNS Domain that you wish to create a zone for
     * @param string $ip     The IP you want the domain to resolve to
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/AddDNSZone XML API Call documentation
     */
     public function adddns($domain, $ip)
@@ -499,14 +499,14 @@ public function adddns($domain, $ip)
     /**
     * Add a record to a zone
     *
-    * This will append a record to a DNS Zone.  The $args argument to this function 
-    * must be an associative array containing information about the DNS zone, please 
+    * This will append a record to a DNS Zone.  The $args argument to this function
+    * must be an associative array containing information about the DNS zone, please
     * see the XML API Call documentation for more info
     *
     * @param string $zone The DNS zone that you want to add the record to
     * @param array  $args Associative array representing the record to be added
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/AddZoneRecord XML API Call documentation
     */
     public function addzonerecord($zone, $args)
@@ -527,8 +527,8 @@ public function addzonerecord($zone, $args)
     * @param string $zone The zone to edit
     * @param int    $line The line number of the zone to edit
     * @param array  $args An associative array representing the zone record
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/EditZoneRecord XML API Call documentation
     * @see    dumpzone()
     */
@@ -539,14 +539,14 @@ public function addzonerecord($zone, $args)
      * @param $zone
      * @param $line
      * @param $args
-     *                
-     * 
+     *
+     *
      * @return
-     *         
+     *
      * @access
      * @static
-     * @see   
-     * @since 
+     * @see
+     * @since
      */
     public function editzonerecord($zone, $line, $args)
     {
@@ -560,12 +560,12 @@ public function editzonerecord($zone, $line, $args)
     /**
     * Retrieve a DNS Record
     *
-    * This function will return a data structure representing a DNS record, to 
+    * This function will return a data structure representing a DNS record, to
     * retrieve all lines see dumpzone.
     * @param string $zone The zone that you want to retrieve a record from
     * @param string $line The line of the zone that you want to retrieve
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/GetZoneRecord XML API Call documentation
     */
     public function getzonerecord($zone, $line)
@@ -581,8 +581,8 @@ public function getzonerecord($zone, $line)
     * This function will remove a DNS Zone from the server
     *
     * @param string $domain The domain to be remove
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/DeleteDNSZone XML API Call documentation
     */
     public function killdns($domain)
@@ -596,10 +596,10 @@ public function killdns($domain)
     }
     /**
     * Return a List of all DNS Zones on the server
-    * 
+    *
     * This XML API function will return an array containing all the DNS Zones on the server
     *
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ListDNSZone XML API Call documentation
     */
@@ -612,8 +612,8 @@ public function listzones()
     *
     * This function will return all records within a zone.
     * @param string $domain The domain to return the records from.
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ListOneZone XML API Call documentation
     * @see    editdnsrecord()
     * @see    getdnsrecord()
@@ -633,8 +633,8 @@ public function dumpzone($domain)
     * This function will return a nameserver's IP
     *
     * @param string $nameserver The nameserver to lookup
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/LookupIP XML API Call documentation
     */
     public function lookupnsip($nameserver)
@@ -669,8 +669,8 @@ public function removezonerecord($zone, $line)
     *
     * This function will reset a zone removing all custom records.  Subdomain records will be readded by scanning the userdata datastore.
     * @param string $domain the domain name of the zone to reset
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ResetZone XML API Call documentation
     */
     public function resetzone($domain)
@@ -685,16 +685,16 @@ public function resetzone($domain)
     //###
     // Package Functions
     //###
-    
+
     /**
     * Add a new package
-    * 
+    *
     * This function will allow you to add a new package
     * This function should be passed an associative array containing elements that define package parameters.
-    * These variables map directly to the parameters for the XML-API Call, please refer to the link below for a complete 
+    * These variables map directly to the parameters for the XML-API Call, please refer to the link below for a complete
     * list of possible variable.  The "name" element is required.
     * @param array $pkg an associative array containing package parameters
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/AddPackage XML API Call documentation
     */
@@ -707,11 +707,11 @@ public function addpkg($pkg)
     }
     /**
     * Remove a package
-    * 
+    *
     * This function allow you to delete a package
     * @param string $pkgname The package you wish to delete
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/DeletePackage XML API Call documentation
     */
     public function killpkg($pkgname)
@@ -730,7 +730,7 @@ public function killpkg($pkgname)
     * the parameters for the package.  The keys within this array map directly to the XML-API call, please see the link
     * below for a list of possible keys within this package.  The name element is required.
     * @param array $pkg An associative array containing new parameters for the package
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/EditPackage XML API Call documentation
     */
@@ -745,7 +745,7 @@ public function editpkg($pkg)
     * List Packages
     *
     * This function will list all packages available to the user
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ListPackages XML API Call documentation
     */
@@ -756,7 +756,7 @@ public function listpkgs()
     //###
     // Reseller functions
     //###
-    
+
     /**
     * Make a user a reseller
     *
@@ -765,8 +765,8 @@ public function listpkgs()
     * @param int    $makeowner Boolean 1 or 0 defining whether the account should own itself or not
     * @see    setacls()
     * @see    setresellerlimits()
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/AddResellerPrivileges XML API Call documentation
     */
     public function setupreseller($username, $makeowner = true)
@@ -792,7 +792,7 @@ public function setupreseller($username, $makeowner = true)
     * Associative Array containing the configuration information for this variable.  Please see the XML API Call documentation
     * For more information.  "acllist" is a required element within this array
     * @param array $acl an associative array describing the parameters for the ACL to be create
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/CreateResellerACLList XML API Call documentation
     */
@@ -807,7 +807,7 @@ public function saveacllist($acl)
     * List available saved ACLs
     *
     * This function will return a list of Saved ACLs for reseller accounts
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ListCurrentResellerACLLists XML API Call documentation
     */
@@ -819,7 +819,7 @@ public function listacls()
     * List Resellers
     *
     * This function will return a list of resellers on the server
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ListResellerAccounts XML API Call documentation
     */
@@ -833,8 +833,8 @@ public function listresellers()
     * This function will return general information on a reseller and all it's account individually such as disk usage and bandwidth usage
     *
     * @param string $username The reseller to be checked
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ListResellersAccountsInformation XML API Call documentation
     */
     public function resellerstats($username)
@@ -852,8 +852,8 @@ public function resellerstats($username)
     * This function will remove an account's reseller privileges, this does not remove the account.
     *
     * @param string $username The username to remove reseller privileges from
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/RemoveResellerPrivileges XML API Call documentation
     */
     public function unsetupreseller($username)
@@ -872,7 +872,7 @@ public function unsetupreseller($username)
     * containing the privleges that this reseller should have access to.  These map directly to the parameters passed to the XML API Call
     * Please view the XML API Call documentation for more information.  "reseller" is the only required element within this array
     * @param array $acl An associative array containing all the ACL information for the reseller
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/SetResellersACLList XML API Call documentation
     */
@@ -890,10 +890,10 @@ public function setacls($acl)
     *
     * @param string  $reseller          the name of the reseller to terminate
     * @param boolean $terminatereseller Passing this as true will terminate the the reseller's account as well as all the accounts owned by the reseller
-    * 
-     * @return mixed  
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/TerminateResellerandAccounts XML API Call documentation
-    *         
+    *
     *         */
     public function terminatereseller($reseller, $terminatereseller = true)
     {
@@ -917,12 +917,12 @@ public function terminatereseller($reseller, $terminatereseller = true)
     /**
     * Set a reseller's dedicated IP addresses
     *
-    * This function will set a reseller's dedicated IP addresses.  If an IP is not passed to this function, 
+    * This function will set a reseller's dedicated IP addresses.  If an IP is not passed to this function,
     * it will reset the reseller to use the server's main shared IP address.
     * @param string $user The username of the reseller to change dedicated IPs for
     * @param string $ip   The IP to assign to the  reseller, this can be a comma-seperated list of IPs to allow for multiple IP addresses
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/SetResellerIps XML API Call documentation
     */
     public function setresellerips($user, $ip = null)
@@ -947,10 +947,10 @@ public function setresellerips($user, $ip = null)
     * Call, please refer to the XML API Call documentation for more information.  The only required parameters is "user"
     *
     * @param array $reseller_cfg An associative array containing configuration information for the specified reseller
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/SetResellerLimits XML API Call documentation
-    *         
+    *
     */
     public function setresellerlimits($reseller_cfg)
     {
@@ -966,8 +966,8 @@ public function setresellerlimits($reseller_cfg)
     * will be created on this IP
     * @param string $reseller the username of the reseller to change the main IP of
     * @param string $ip       The ip you would like this reseller to create accounts on by default
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/SetResellerMainIp XML API Call documentation
     */
     public function setresellermainip($reseller, $ip)
@@ -989,8 +989,8 @@ public function setresellermainip($reseller, $ip)
     * @param string  $package  if $no_limit is false, then the package you wish to modify privileges for
     * @param boolean $allowed  if $no_limit is false, then defines if the reseller should have access to the package or not
     * @param int     $number   if $no_limit is false, then defines the number of account a reseller can create of a specific package
-    * 
-     * @return mixed  
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/SetResellerPkgLimit XML API Call documentation
     */
     public function setresellerpackagelimits($user, $no_limit, $package = null, $allowed = null, $number = null)
@@ -1028,8 +1028,8 @@ public function setresellerpackagelimits($user, $no_limit, $package = null, $all
     * This function, when called will suspend a reseller account and all account owned by said reseller
     * @param string $reseller The reseller account to be suspended
     * @param string $reason   (optional) The reason for suspending the reseller account
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/SuspendReseller XML API Call documentation
     */
     public function suspendreseller($reseller, $reason = null)
@@ -1050,8 +1050,8 @@ public function suspendreseller($reseller, $reason = null)
     *
     * This function will unsuspend a reseller account and all accounts owned by the reseller in question
     * @param string $user The username of the reseller to be unsuspended
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/UnsuspendReseller XML API Call documentation
     */
     public function unsuspendreseller($user)
@@ -1068,8 +1068,8 @@ public function unsuspendreseller($user)
     *
     * This function will return the number of accounts owned by a reseller account, along with information such as the number of active, suspended and accounting limits
     * @param string $user The username of the reseller to get account information from
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/AcctCounts XML API Call documentation
     */
     public function acctcounts($user)
@@ -1088,8 +1088,8 @@ public function acctcounts($user)
     * If this function is not passed a $nameservers parameter, it will reset the nameservers for the reseller to the servers's default
     * @param string $user        The username of the reseller account to grab reseller accounts from
     * @param string $nameservers A comma seperate list of nameservers
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/SetResellerNameservers XML API Call documentation
     */
     public function setresellernameservers($user, $nameservers = null)
@@ -1108,12 +1108,12 @@ public function setresellernameservers($user, $nameservers = null)
     //###
     // Server information
     //###
-    
+
     /**
     * Get a server's hostname
     *
     * This function will return a server's hostname
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/DisplayServerHostname XML API Call documentation
     */
@@ -1125,7 +1125,7 @@ public function gethostname()
     * Get the version of cPanel running on the server
     *
     * This function will return the version of cPanel/WHM running on the remote system
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/DisplaycPanelWHMVersion XML API Call documentation
     */
@@ -1138,7 +1138,7 @@ public function version()
     *
     * This function will return the loadavg of the remote system
     *
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/LoadAvg XML API Call documentation
     */
@@ -1150,10 +1150,10 @@ public function loadavg()
     * Get a list of languages on the remote system
     *
     * This function will return a list of available langauges for the cPanel interface
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/GetLangList XML API Call documentation
-    *         
+    *
     */
     public function getlanglist()
     {
@@ -1162,14 +1162,14 @@ public function getlanglist()
     //###
     // Server administration
     //###
-    
+
     /**
     * Reboot server
     *
     * This function will reboot the server
     * @param boolean $force This will determine if the server should be given a graceful or forceful reboot
-    * 
-     * @return mixed  
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/RebootServer XML API Call documentation
     */
     public function reboot($force = false)
@@ -1187,8 +1187,8 @@ public function reboot($force = false)
     * This function will add an IP alias to your server
     * @param string $ip      The IP to be added
     * @param string $netmask The netmask of the IP to be added
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/AddIPAddress XML API Call documentation
     */
     public function addip($ip, $netmask)
@@ -1202,7 +1202,7 @@ public function addip($ip, $netmask)
         ));
     }
     // This function allows you to delete an IP address from your server.
-    
+
     /**
     * Delete an IP from a server
     *
@@ -1210,8 +1210,8 @@ public function addip($ip, $netmask)
     * @param string $ip             The IP to remove
     * @param string $ethernetdev    The ethernet device that the IP is bound to
     * @param bool   $skipifshutdown Whether the function should remove the IP even if the ethernet interface is down
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/DeleteIPAddress XML API Call documentation
     */
     public function delip($ip, $ethernetdev = null, $skipifshutdown = false)
@@ -1231,7 +1231,7 @@ public function delip($ip, $ethernetdev = null, $skipifshutdown = false)
     * List IPs
     *
     * This should return a list of IPs on a server
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/DeleteIPAddress XML API Call documentation
     */
@@ -1244,8 +1244,8 @@ public function listips()
     *
     * This function will allow you to set the hostname of the server
     * @param string $hostname the hostname that should be assigned to the serve
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/SetHostname XML API Call documentation
     */
     public function sethostname($hostname)
@@ -1259,14 +1259,14 @@ public function sethostname($hostname)
     }
     /**
     * Set the resolvers used by the server
-    * 
+    *
     * This function will set the resolvers in /etc/resolv.conf for the server
     * @param string $nameserver1 The IP of the first nameserver to use
     * @param string $nameserver2 The IP of the second namesever to use
     * @param string $nameserver3 The IP of the third nameserver to use
     * @param string $nameserver4 The IP of the forth nameserver to use
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/SetResolvers XML API Call documentation
     */
     public function setresolvers($nameserver1, $nameserver2 = null, $nameserver3 = null)
@@ -1291,7 +1291,7 @@ public function setresolvers($nameserver1, $nameserver2 = null, $nameserver3 = n
     * The arguments for this can be passed in via an associative array, the elements of this array map directly to the
     * parameters of the call, please see the XML API Call documentation for more information
     * @param array $args The configuration for what bandwidth information to display
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ShowBw XML API Call documentation
     */
@@ -1306,16 +1306,16 @@ public function showbw($args = null)
      * nvset
      * Insert description here
      *
-     * @param $key  
+     * @param $key
      * @param $value
-     *                 
-     * 
+     *
+     *
      * @return
-     *         
+     *
      * @access
      * @static
-     * @see   
-     * @since 
+     * @see
+     * @since
      */
     public function nvset($key, $value)
     {
@@ -1328,20 +1328,20 @@ public function nvset($key, $value)
         ));
     }
     // This function allows you to retrieve and view a non-volatile variable's value.
-    
+
     /**
      * nvget
      * Insert description here
      *
      * @param $key
-     *               
-     * 
+     *
+     *
      * @return
-     *         
+     *
      * @access
      * @static
-     * @see   
-     * @since 
+     * @see
+     * @since
      */
     public function nvget($key)
     {
@@ -1355,14 +1355,14 @@ public function nvget($key)
     //###
     // Service functions
     //###
-    
+
     /**
     * Restart a Service
     *
     * This function allows you to restart a service on the server
     * @param string $service the service that you wish to restart please view the XML API Call documentation for acceptable values to this parameters
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/RestartService XML API Call documentation
     */
     public function restartsrv($service)
@@ -1378,7 +1378,7 @@ public function restartsrv($service)
     * Service Status
     *
     * This function will return the status of all services on the and whether they are running or not
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ServiceStatus XML API Call documentation
     */
@@ -1393,8 +1393,8 @@ public function servicestatus()
     * @param string $service   The service to be monitored
     * @param bool   $enabled   Whether the service should be enabled or not
     * @param bool   $monitored Whether the service should be monitored or not
-    * 
-     * @return mixed 
+    *
+     * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ConfigureService XML API Call documentation
     */
     public function configureservice($service, $enabled = true, $monitored = true)
@@ -1420,13 +1420,13 @@ public function configureservice($service, $enabled = true, $monitored = true)
     //###
     // SSL functions
     //###
-    
+
     /**
     * Display information on an SSL host
     *
     * This function will return information on an SSL Certificate, CSR, cabundle and SSL key for a specified domain
     * @param array $args Configuration information for the SSL certificate, please see XML API Call documentation for required values
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/FetchSSL XML API Call documentation
     */
@@ -1446,7 +1446,7 @@ public function fetchsslinfo($args)
     *
     * This function will generate an SSL Certificate, the arguments for this map directly to the call for the XML API call.  Please consult the XML API Call documentation for more information
     * @param array $args the configuration for the SSL Certificate being generated
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/GenerateSSL XML API Call documentation
     */
@@ -1460,10 +1460,10 @@ public function generatessl($args)
     /**
     * Install an SSL certificate
     *
-    * This function will allow you to install an SSL certificate that is uploaded via the $argument parameter to this call.  The arguments for this call map directly to the parameters for the XML API call, 
+    * This function will allow you to install an SSL certificate that is uploaded via the $argument parameter to this call.  The arguments for this call map directly to the parameters for the XML API call,
     * please consult the XML API Call documentation for more information.
     * @param array $args The configuration for the SSL certificate
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/InstallSSL XML API Call documentation
     */
@@ -1478,7 +1478,7 @@ public function installssl($args)
     * List SSL Certs
     *
     * This function will list all SSL certificates installed on the server
-    * 
+    *
      * @return mixed
     * @link   http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AutomationIntegration/ListSSL XML API Call documentation
     */
@@ -1487,4 +1487,4 @@ public function listcrts()
         return $this->makeQuery('listcrts');
     }
 }
-?>
\ No newline at end of file
+?>
diff --git a/library/Cpanel/Service/cPanel.php b/library/Cpanel/Service/cPanel.php
index f78b74c7..4c0187c2 100755
--- a/library/Cpanel/Service/cPanel.php
+++ b/library/Cpanel/Service/cPanel.php
@@ -1,7 +1,7 @@
 <?php
 /**
  * Cpanel_Service_cPanel
- * 
+ *
  * Copyright (c) 2011, cPanel, Inc.
  * All rights reserved.
  * http://cpanel.net
@@ -27,25 +27,25 @@
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- * 
+ *
  * @category  Cpanel
  * @package   Cpanel_Service
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
  */
-/** 
+/**
  * cPanel Service class
  *
  * @class     Cpanel_Service_cPanel
  * @category  Cpanel
  * @package   Cpanel_Service
  * @author    David Neimeyer <david.neimeyer@cpanel.net>
- * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net) 
- * @license   http://sdk.cpanel.net/license/bsd.html BSD License 
+ * @copyright Copyright (c) 2011, cPanel, Inc., All rights Reserved. (http://cpanel.net)
+ * @license   http://sdk.cpanel.net/license/bsd.html BSD License
  * @version   0.1.0
  * @link      http://sdk.cpanel.net
  * @since     0.1.0
@@ -58,14 +58,14 @@ class Cpanel_Service_cPanel extends Cpanel_Service_Abstract
     const ADAPTER_DEFAULT = 'cpanel';
     /**
      * Constructor
-     * 
+     *
      * @param arrays $optsArray Option configuration data
-     * 
+     *
      * @return Cpanel_Service_cPanel
      */
     public function __construct($optsArray = array())
     {
-        if (!count($optsArray)) {
+        if (!is_array($optsArray) || !count($optsArray)) {
             $opts = array();
         }
         if (array_key_exists('config', $optsArray)) {
@@ -86,9 +86,9 @@ public function __construct($optsArray = array())
     }
     /**
      * Fetch default adapter name for WHM service
-     * 
+     *
      * @see    Cpanel_Service_Abstract::getDefaultAdapterName()
-     * 
+     *
      * @return string
      */
     public function getDefaultAdapterName()
@@ -97,13 +97,13 @@ public function getDefaultAdapterName()
     }
     /**
      * Validate a given string corresponds to a usable adapter type
-     * 
+     *
      * NOTE: will normalize $type for use in other methods
-     * 
+     *
      * @param string $type service adapter name to validate
-     * 
+     *
      * @see    Cpanel_Service_Abstract::validAdapter()
-     * 
+     *
      * @return string|bool String of normalized $type, if valid, otherwise false
      */
     public function validAdapter($type)
@@ -126,11 +126,11 @@ public function validAdapter($type)
     }
     /**
      * Spawn a new adapter object based on valid service adapter name
-     * 
+     *
      * @param string $adapterType Valid service adapter name
-     * 
+     *
      * @see    Cpanel_Service_Abstract::spawnAdapter()
-     * 
+     *
      * @return Cpanel_Service_Adapter_Cpanelapi|Cpanel_Service_Adapter_WHMapi|Cpanel_Service_Adapter_Liveapi
      */
     protected function spawnAdapter($adapterType)
@@ -157,12 +157,12 @@ protected function spawnAdapter($adapterType)
     }
     /**
      * Make an API1 cPanel query for a given service
-     * 
+     *
      * @param string $aservice service adapter name
      * @param array  $mf       Any required parameters for constructing the call
      *  like module and function
      * @param array  $args     Arguments for the API1 call, ordinal array
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     public function api1_request($aservice, $mf, $args = array())
@@ -171,8 +171,8 @@ public function api1_request($aservice, $mf, $args = array())
         $rObj = $this->genResponseObject($aservice);
         $a = $this->getAdapter($rObj);
         /**
-         * TODO: handle more dynamically; 
-         *  need logic for user set before query request. 
+         * TODO: handle more dynamically;
+         *  need logic for user set before query request.
          *  prob need a set/get_output type meth.
          */
         $rObj->setResponseFormatType($a->getAdapterResponseFormatType());
@@ -187,12 +187,12 @@ public function api1_request($aservice, $mf, $args = array())
     }
     /**
      * Make an API2 cPanel query for a given service
-     * 
+     *
      * @param string $aservice service adapter name
      * @param array  $mf       Any required parameters for constructing the call
      *  like module and function
      * @param array  $args     Arguments for the API2 call, associative array
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     public function api2_request($aservice, $mf, $args = array())
@@ -212,11 +212,11 @@ public function api2_request($aservice, $mf, $args = array())
     }
     /**
      * Direct URL query method for PublicAPI client
-     * 
+     *
      * @param string $uri          URL to query
      * @param array  $formdata     Array of URL parameters
      * @param array  $queryOptions Array of options for query mechanism
-     * 
+     *
      * @return Cpanel_Query_Object
      */
     public function directURLQuery($uri, $formdata, $queryOptions = array())
@@ -241,10 +241,10 @@ public function directURLQuery($uri, $formdata, $queryOptions = array())
     }
     /**
      * Set a mode for a stored adapter
-     * 
+     *
      * @param string $adapterType The adapter to modify
      * @param string $mode        Mode to set
-     * 
+     *
      * @return Cpanel_Service_cPanel
      */
     public function setAdapterMode($adapterType, $mode)
@@ -258,10 +258,10 @@ public function setAdapterMode($adapterType, $mode)
     }
     /**
      * Unset a mode for a stored adapter
-     * 
+     *
      * @param string $adapterType The adapter to modify
      * @param string $mode        Mode to unset
-     * 
+     *
      * @return Cpanel_Service_cPanel
      */
     public function unsetAdapterMode($adapterType, $mode)
@@ -276,13 +276,13 @@ public function unsetAdapterMode($adapterType, $mode)
     /**
      * Get the current adapter, spawn if necessary, and call requested method on
      * it.
-     * 
+     *
      * NOTE: It's assumed that the adapter implements it's own measure to throw
      * if the method is undefined
      *
      * @param string $method Method to invoke on adapter
      * @param array  $args   Method arguments
-     * 
+     *
      * @return mixed   The result of the success adapter method call
      */
     public function __call($method, $args)
@@ -300,4 +300,4 @@ public function __call($method, $args)
         );
     }
 }
-?>
\ No newline at end of file
+?>
diff --git a/library/IDNA/Convert.php b/library/IDNA/Convert.php
index f353295e..483e7a52 100644
--- a/library/IDNA/Convert.php
+++ b/library/IDNA/Convert.php
@@ -1,2701 +1,2701 @@
-<?php
-// {{{ license
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
-//
-// +----------------------------------------------------------------------+
-// | This library is free software; you can redistribute it and/or modify |
-// | it under the terms of the GNU Lesser General Public License as       |
-// | published by the Free Software Foundation; either version 2.1 of the |
-// | License, or (at your option) any later version.                      |
-// |                                                                      |
-// | This library 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    |
-// | Lesser General Public License for more details.                      |
-// |                                                                      |
-// | You should have received a copy of the GNU Lesser General Public     |
-// | License along with this library; if not, write to the Free Software  |
-// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 |
-// | USA.                                                                 |
-// +----------------------------------------------------------------------+
-//
-
-// }}}
-
-/**
- * Encode/decode Internationalized Domain Names.
- *
- * The class allows to convert internationalized domain names
- * (see RFC 3490 for details) as they can be used with various registries worldwide
- * to be translated between their original (localized) form and their encoded form
- * as it will be used in the DNS (Domain Name System).
- *
- * The class provides two public methods, encode() and decode(), which do exactly
- * what you would expect them to do. You are allowed to use complete domain names,
- * simple strings and complete email addresses as well. That means, that you might
- * use any of the following notations:
- *
- * - www.n�rgler.com
- * - xn--nrgler-wxa
- * - xn--brse-5qa.xn--knrz-1ra.info
- *
- * Unicode input might be given as either UTF-8 string, UCS-4 string or UCS-4
- * array. Unicode output is available in the same formats.
- * You can select your preferred format via {@link set_paramter()}.
- *
- * ACE input and output is always expected to be ASCII.
- *
- * @author  Matthias Sommerfeld <mso@phlylabs.de>
- * @author  Leonid Kogan <lko@neuse.de>
- * @copyright 2004-2008 phlyLabs Berlin, http://phlylabs.de
- * @version 0.6.0
- * @changelog since 0.5.1 class updated to PHP5/6 style should be compatible to PHP 4.3+
- *
- */
-class IDNA_Convert
-{
-    // NP See below
-
-    // Internal settings, do not mess with them
-    private $_punycode_prefix = 'xn--';
-    private $_invalid_ucs = 0x80000000;
-    private $_max_ucs = 0x10FFFF;
-    private $_base = 36;
-    private $_tmin = 1;
-    private $_tmax = 26;
-    private $_skew = 38;
-    private $_damp = 700;
-    private $_initial_bias = 72;
-    private $_initial_n = 0x80;
-    private $_sbase = 0xAC00;
-    private $_lbase = 0x1100;
-    private $_vbase = 0x1161;
-    private $_tbase = 0x11A7;
-    private $_lcount = 19;
-    private $_vcount = 21;
-    private $_tcount = 28;
-    private $_ncount = 588;   // _vcount * _tcount
-    private $_scount = 11172; // _lcount * _tcount * _vcount
-    private $_error = false;
-
-    // See {@link set_paramter()} for details of how to change the following
-    // settings from within your script / application
-    private $_api_encoding = 'utf8';  // Default input charset is UTF-8
-    private $_allow_overlong = false; // Overlong UTF-8 encodings are forbidden
-    private $_strict_mode = false;    // Behave strict or not
-
-
-    /**
-     * the constructor
-     *
-     * @param array $options
-     * @return boolean
-     * @since 0.5.2
-     */
-    public function __construct($options = false)
-    {
-        $this->slast = $this->_sbase + $this->_lcount * $this->_vcount * $this->_tcount;
-        // If parameters are given, pass these to the respective method
-        if (is_array($options)) return $this->set_parameter($options);
-        return true;
-    }
-
-    /**
-     * Sets a new option value. Available options and values:
-     * [encoding - Use either UTF-8, UCS4 as array or UCS4 as string as input ('utf8' for UTF-8,
-     *         'ucs4_string' and 'ucs4_array' respectively for UCS4); The output is always UTF-8]
-     * [overlong - Unicode does not allow unnecessarily long encodings of chars,
-     *             to allow this, set this parameter to true, else to false;
-     *             default is false.]
-     * [strict - true: strict mode, good for registration purposes - Causes errors
-     *           on failures; false: loose mode, ideal for "wildlife" applications
-     *           by silently ignoring errors and returning the original input instead
-     *
-     * @param    mixed     Parameter to set (string: single parameter; array of Parameter => Value pairs)
-     * @param    string    Value to use (if parameter 1 is a string)
-     * @return   boolean   true on success, false otherwise
-     */
-    public function set_parameter($option, $value = false)
-    {
-        if (!is_array($option)) {
-            $option = array($option => $value);
-        }
-        foreach ($option as $k => $v) {
-            switch ($k) {
-            case 'encoding':
-                switch ($v) {
-                case 'utf8':
-                case 'ucs4_string':
-                case 'ucs4_array':
-                    $this->_api_encoding = $v;
-                    break;
-                default:
-                    $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k);
-                    return false;
-                }
-                break;
-            case 'overlong':
-                $this->_allow_overlong = ($v) ? true : false;
-                break;
-            case 'strict':
-                $this->_strict_mode = ($v) ? true : false;
-                break;
-            default:
-                $this->_error('Set Parameter: Unknown option '.$k);
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Decode a given ACE domain name
-     * @param    string   Domain name (ACE string)
-     * [@param    string   Desired output encoding, see {@link set_parameter}]
-     * @return   string   Decoded Domain name (UTF-8 or UCS-4)
-     */
-    public function decode($input, $one_time_encoding = false)
-    {
-        // Optionally set
-        if ($one_time_encoding) {
-            switch ($one_time_encoding) {
-            case 'utf8':
-            case 'ucs4_string':
-            case 'ucs4_array':
-                break;
-            default:
-                $this->_error('Unknown encoding '.$one_time_encoding);
-                return false;
-            }
-        }
-        // Make sure to drop any newline characters around
-        $input = trim($input);
-
-        // Negotiate input and try to determine, whether it is a plain string,
-        // an email address or something like a complete URL
-        if (strpos($input, '@')) { // Maybe it is an email address
-            // No no in strict mode
-            if ($this->_strict_mode) {
-                $this->_error('Only simple domain name parts can be handled in strict mode');
-                return false;
-            }
-            list ($email_pref, $input) = explode('@', $input, 2);
-            $arr = explode('.', $input);
-            foreach ($arr as $k => $v) {
-                if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
-                    $conv = $this->_decode($v);
-                    if ($conv) $arr[$k] = $conv;
-                }
-            }
-            $input = join('.', $arr);
-            $arr = explode('.', $email_pref);
-            foreach ($arr as $k => $v) {
-                if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
-                    $conv = $this->_decode($v);
-                    if ($conv) $arr[$k] = $conv;
-                }
-            }
-            $email_pref = join('.', $arr);
-            $return = $email_pref . '@' . $input;
-        } elseif (preg_match('![:\./]!', $input)) { // Or a complete domain name (with or without paths / parameters)
-            // No no in strict mode
-            if ($this->_strict_mode) {
-                $this->_error('Only simple domain name parts can be handled in strict mode');
-                return false;
-            }
-            $parsed = parse_url($input);
-            if (isset($parsed['host'])) {
-                $arr = explode('.', $parsed['host']);
-                foreach ($arr as $k => $v) {
-                    $conv = $this->_decode($v);
-                    if ($conv) $arr[$k] = $conv;
-                }
-                $parsed['host'] = join('.', $arr);
-                $return =
-                        (empty($parsed['scheme']) ? '' : $parsed['scheme'].(strtolower($parsed['scheme']) == 'mailto' ? ':' : '://'))
-                        .(empty($parsed['user']) ? '' : $parsed['user'].(empty($parsed['pass']) ? '' : ':'.$parsed['pass']).'@')
-                        .$parsed['host']
-                        .(empty($parsed['port']) ? '' : ':'.$parsed['port'])
-                        .(empty($parsed['path']) ? '' : $parsed['path'])
-                        .(empty($parsed['query']) ? '' : '?'.$parsed['query'])
-                        .(empty($parsed['fragment']) ? '' : '#'.$parsed['fragment']);
-            } else { // parse_url seems to have failed, try without it
-                $arr = explode('.', $input);
-                foreach ($arr as $k => $v) {
-                    $conv = $this->_decode($v);
-                    $arr[$k] = ($conv) ? $conv : $v;
-                }
-                $return = join('.', $arr);
-            }
-        } else { // Otherwise we consider it being a pure domain name string
-            $return = $this->_decode($input);
-            if (!$return) $return = $input;
-        }
-        // The output is UTF-8 by default, other output formats need conversion here
-        // If one time encoding is given, use this, else the objects property
-        switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) {
-        case 'utf8':
-            return $return;
-            break;
-        case 'ucs4_string':
-           return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return));
-           break;
-        case 'ucs4_array':
-            return $this->_utf8_to_ucs4($return);
-            break;
-        default:
-            $this->_error('Unsupported output format');
-            return false;
-        }
-    }
-
-    /**
-     * Encode a given UTF-8 domain name
-     * @param    string   Domain name (UTF-8 or UCS-4)
-     * [@param    string   Desired input encoding, see {@link set_parameter}]
-     * @return   string   Encoded Domain name (ACE string)
-     */
-    public function encode($decoded, $one_time_encoding = false)
-    {
-        // Forcing conversion of input to UCS4 array
-        // If one time encoding is given, use this, else the objects property
-        switch ($one_time_encoding ? $one_time_encoding : $this->_api_encoding) {
-        case 'utf8':
-            $decoded = $this->_utf8_to_ucs4($decoded);
-            break;
-        case 'ucs4_string':
-           $decoded = $this->_ucs4_string_to_ucs4($decoded);
-        case 'ucs4_array':
-           break;
-        default:
-            $this->_error('Unsupported input format: '.($one_time_encoding ? $one_time_encoding : $this->_api_encoding));
-            return false;
-        }
-
-        // No input, no output, what else did you expect?
-        if (empty($decoded)) return '';
-
-        // Anchors for iteration
-        $last_begin = 0;
-        // Output string
-        $output = '';
-        foreach ($decoded as $k => $v) {
-            // Make sure to use just the plain dot
-            switch($v) {
-            case 0x3002:
-            case 0xFF0E:
-            case 0xFF61:
-                $decoded[$k] = 0x2E;
-                // Right, no break here, the above are converted to dots anyway
-            // Stumbling across an anchoring character
-            case 0x2E:
-            case 0x2F:
-            case 0x3A:
-            case 0x3F:
-            case 0x40:
-                // Neither email addresses nor URLs allowed in strict mode
-                if ($this->_strict_mode) {
-                   $this->_error('Neither email addresses nor URLs are allowed in strict mode.');
-                   return false;
-                } else {
-                    // Skip first char
-                    if ($k) {
-                        $encoded = '';
-                        $encoded = $this->_encode(array_slice($decoded, $last_begin, (($k)-$last_begin)));
-                        if ($encoded) {
-                            $output .= $encoded;
-                        } else {
-                            $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($k)-$last_begin)));
-                        }
-                        $output .= chr($decoded[$k]);
-                    }
-                    $last_begin = $k + 1;
-                }
-            }
-        }
-        // Catch the rest of the string
-        if ($last_begin) {
-            $inp_len = sizeof($decoded);
-            $encoded = '';
-            $encoded = $this->_encode(array_slice($decoded, $last_begin, (($inp_len)-$last_begin)));
-            if ($encoded) {
-                $output .= $encoded;
-            } else {
-                $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($inp_len)-$last_begin)));
-            }
-            return $output;
-        } else {
-            if ($output = $this->_encode($decoded)) {
-                return $output;
-            } else {
-                return $this->_ucs4_to_utf8($decoded);
-            }
-        }
-    }
-
-    /**
-     * Use this method to get the last error ocurred
-     * @param    void
-     * @return   string   The last error, that occured
-     */
-    public function get_last_error()
-    {
-        return $this->_error;
-    }
-
-    /**
-     * The actual decoding algorithm
-     * @param string
-     * @return mixed
-     */
-    private function _decode($encoded)
-    {
-        $decoded = array();
-        // find the Punycode prefix
-        if (!preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $encoded)) {
-            $this->_error('This is not a punycode string');
-            return false;
-        }
-        $encode_test = preg_replace('!^'.preg_quote($this->_punycode_prefix, '!').'!', '', $encoded);
-        // If nothing left after removing the prefix, it is hopeless
-        if (!$encode_test) {
-            $this->_error('The given encoded string was empty');
-            return false;
-        }
-        // Find last occurence of the delimiter
-        $delim_pos = strrpos($encoded, '-');
-        if ($delim_pos > strlen($this->_punycode_prefix)) {
-            for ($k = strlen($this->_punycode_prefix); $k < $delim_pos; ++$k) {
-                $decoded[] = ord($encoded{$k});
-            }
-        }
-        $deco_len = count($decoded);
-        $enco_len = strlen($encoded);
-
-        // Wandering through the strings; init
-        $is_first = true;
-        $bias = $this->_initial_bias;
-        $idx = 0;
-        $char = $this->_initial_n;
-
-        for ($enco_idx = ($delim_pos) ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) {
-            for ($old_idx = $idx, $w = 1, $k = $this->_base; 1 ; $k += $this->_base) {
-                $digit = $this->_decode_digit($encoded{$enco_idx++});
-                $idx += $digit * $w;
-                $t = ($k <= $bias) ? $this->_tmin :
-                        (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias));
-                if ($digit < $t) break;
-                $w = (int) ($w * ($this->_base - $t));
-            }
-            $bias = $this->_adapt($idx - $old_idx, $deco_len + 1, $is_first);
-            $is_first = false;
-            $char += (int) ($idx / ($deco_len + 1));
-            $idx %= ($deco_len + 1);
-            if ($deco_len > 0) {
-                // Make room for the decoded char
-                for ($i = $deco_len; $i > $idx; $i--) $decoded[$i] = $decoded[($i - 1)];
-            }
-            $decoded[$idx++] = $char;
-        }
-        return $this->_ucs4_to_utf8($decoded);
-    }
-
-    /**
-     * The actual encoding algorithm
-     * @param  string
-     * @return mixed
-     */
-    private function _encode($decoded)
-    {
-        // We cannot encode a domain name containing the Punycode prefix
-        $extract = strlen($this->_punycode_prefix);
-        $check_pref = $this->_utf8_to_ucs4($this->_punycode_prefix);
-        $check_deco = array_slice($decoded, 0, $extract);
-
-        if ($check_pref == $check_deco) {
-            $this->_error('This is already a punycode string');
-            return false;
-        }
-        // We will not try to encode strings consisting of basic code points only
-        $encodable = false;
-        foreach ($decoded as $k => $v) {
-            if ($v > 0x7a) {
-                $encodable = true;
-                break;
-            }
-        }
-        if (!$encodable) {
-            $this->_error('The given string does not contain encodable chars');
-            return false;
-        }
-        // Do NAMEPREP
-        $decoded = $this->_nameprep($decoded);
-        if (!$decoded || !is_array($decoded)) return false; // NAMEPREP failed
-        $deco_len  = count($decoded);
-        if (!$deco_len) return false; // Empty array
-        $codecount = 0; // How many chars have been consumed
-        $encoded = '';
-        // Copy all basic code points to output
-        for ($i = 0; $i < $deco_len; ++$i) {
-            $test = $decoded[$i];
-            // Will match [-0-9a-zA-Z]
-            if ((0x2F < $test && $test < 0x40) || (0x40 < $test && $test < 0x5B)
-                    || (0x60 < $test && $test <= 0x7B) || (0x2D == $test)) {
-                $encoded .= chr($decoded[$i]);
-                $codecount++;
-            }
-        }
-        if ($codecount == $deco_len) return $encoded; // All codepoints were basic ones
-
-        // Start with the prefix; copy it to output
-        $encoded = $this->_punycode_prefix.$encoded;
-        // If we have basic code points in output, add an hyphen to the end
-        if ($codecount) $encoded .= '-';
-        // Now find and encode all non-basic code points
-        $is_first = true;
-        $cur_code = $this->_initial_n;
-        $bias = $this->_initial_bias;
-        $delta = 0;
-        while ($codecount < $deco_len) {
-            // Find the smallest code point >= the current code point and
-            // remember the last ouccrence of it in the input
-            for ($i = 0, $next_code = $this->_max_ucs; $i < $deco_len; $i++) {
-                if ($decoded[$i] >= $cur_code && $decoded[$i] <= $next_code) {
-                    $next_code = $decoded[$i];
-                }
-            }
-            $delta += ($next_code - $cur_code) * ($codecount + 1);
-            $cur_code = $next_code;
-
-            // Scan input again and encode all characters whose code point is $cur_code
-            for ($i = 0; $i < $deco_len; $i++) {
-                if ($decoded[$i] < $cur_code) {
-                    $delta++;
-                } elseif ($decoded[$i] == $cur_code) {
-                    for ($q = $delta, $k = $this->_base; 1; $k += $this->_base) {
-                        $t = ($k <= $bias) ? $this->_tmin :
-                                (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias);
-                        if ($q < $t) break;
-                        $encoded .= $this->_encode_digit(intval($t + (($q - $t) % ($this->_base - $t)))); //v0.4.5 Changed from ceil() to intval()
-                        $q = (int) (($q - $t) / ($this->_base - $t));
-                    }
-                    $encoded .= $this->_encode_digit($q);
-                    $bias = $this->_adapt($delta, $codecount+1, $is_first);
-                    $codecount++;
-                    $delta = 0;
-                    $is_first = false;
-                }
-            }
-            $delta++;
-            $cur_code++;
-        }
-        return $encoded;
-    }
-
-    /**
-     * Adapt the bias according to the current code point and position
-     * @param int $delta
-     * @param int $npoints
-     * @param int $is_first
-     * @return int
-     */
-    private function _adapt($delta, $npoints, $is_first)
-    {
-        $delta = intval($is_first ? ($delta / $this->_damp) : ($delta / 2));
-        $delta += intval($delta / $npoints);
-        for ($k = 0; $delta > (($this->_base - $this->_tmin) * $this->_tmax) / 2; $k += $this->_base) {
-            $delta = intval($delta / ($this->_base - $this->_tmin));
-        }
-        return intval($k + ($this->_base - $this->_tmin + 1) * $delta / ($delta + $this->_skew));
-    }
-
-    /**
-     * Encoding a certain digit
-     * @param    int $d
-     * @return string
-     */
-    private function _encode_digit($d)
-    {
-        return chr($d + 22 + 75 * ($d < 26));
-    }
-
-    /**
-     * Decode a certain digit
-     * @param    int $cp
-     * @return int
-     */
-    private function _decode_digit($cp)
-    {
-        $cp = ord($cp);
-        return ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $this->_base));
-    }
-
-    /**
-     * Internal error handling method
-     * @param  string $error
-     */
-    private function _error($error = '')
-    {
-        $this->_error = $error;
-    }
-
-    /**
-     * Do Nameprep according to RFC3491 and RFC3454
-     * @param    array    Unicode Characters
-     * @return   string   Unicode Characters, Nameprep'd
-     */
-    private function _nameprep($input)
-    {
-        $output = array();
-        $error = false;
-        //
-        // Mapping
-        // Walking through the input array, performing the required steps on each of
-        // the input chars and putting the result into the output array
-        // While mapping required chars we apply the cannonical ordering
-        foreach ($input as $v) {
-            // Map to nothing == skip that code point
-            if (in_array($v, $this->NP['map_nothing'])) continue;
-            // Try to find prohibited input
-            if (in_array($v, $this->NP['prohibit']) || in_array($v, $this->NP['general_prohibited'])) {
-                $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
-                return false;
-            }
-            foreach ($this->NP['prohibit_ranges'] as $range) {
-                if ($range[0] <= $v && $v <= $range[1]) {
-                    $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
-                    return false;
-                }
-            }
-            // Hangul syllable decomposition
-            if (0xAC00 <= $v && $v <= 0xD7AF) {
-                foreach ($this->_hangul_decompose($v) as $out) $output[] = (int) $out;
-            // There's a decomposition mapping for that code point
-            } elseif (isset($this->NP['replacemaps'][$v])) {
-                foreach ($this->_apply_cannonical_ordering($this->NP['replacemaps'][$v]) as $out) {
-                    $output[] = (int) $out;
-                }
-            } else {
-                $output[] = (int) $v;
-            }
-        }
-        // Before applying any Combining, try to rearrange any Hangul syllables
-        $output = $this->_hangul_compose($output);
-        //
-        // Combine code points
-        //
-        $last_class = 0;
-        $last_starter = 0;
-        $out_len = count($output);
-        for ($i = 0; $i < $out_len; ++$i) {
-            $class = $this->_get_combining_class($output[$i]);
-            if ((!$last_class || $last_class > $class) && $class) {
-                // Try to match
-                $seq_len = $i - $last_starter;
-                $out = $this->_combine(array_slice($output, $last_starter, $seq_len));
-                // On match: Replace the last starter with the composed character and remove
-                // the now redundant non-starter(s)
-                if ($out) {
-                    $output[$last_starter] = $out;
-                    if (count($out) != $seq_len) {
-                        for ($j = $i+1; $j < $out_len; ++$j) $output[$j-1] = $output[$j];
-                        unset($output[$out_len]);
-                    }
-                    // Rewind the for loop by one, since there can be more possible compositions
-                    $i--;
-                    $out_len--;
-                    $last_class = ($i == $last_starter) ? 0 : $this->_get_combining_class($output[$i-1]);
-                    continue;
-                }
-            }
-            // The current class is 0
-            if (!$class) $last_starter = $i;
-            $last_class = $class;
-        }
-        return $output;
-    }
-
-    /**
-     * Decomposes a Hangul syllable
-     * (see http://www.unicode.org/unicode/reports/tr15/#Hangul
-     * @param    integer  32bit UCS4 code point
-     * @return   array    Either Hangul Syllable decomposed or original 32bit value as one value array
-     */
-    private function _hangul_decompose($char)
-    {
-        $sindex = (int) $char - $this->_sbase;
-        if ($sindex < 0 || $sindex >= $this->_scount) return array($char);
-        $result = array();
-        $result[] = (int) $this->_lbase + $sindex / $this->_ncount;
-        $result[] = (int) $this->_vbase + ($sindex % $this->_ncount) / $this->_tcount;
-        $T = intval($this->_tbase + $sindex % $this->_tcount);
-        if ($T != $this->_tbase) $result[] = $T;
-        return $result;
-    }
-    /**
-     * Ccomposes a Hangul syllable
-     * (see http://www.unicode.org/unicode/reports/tr15/#Hangul
-     * @param    array    Decomposed UCS4 sequence
-     * @return   array    UCS4 sequence with syllables composed
-     */
-    private function _hangul_compose($input)
-    {
-        $inp_len = count($input);
-        if (!$inp_len) return array();
-        $result = array();
-        $last = (int) $input[0];
-        $result[] = $last; // copy first char from input to output
-
-        for ($i = 1; $i < $inp_len; ++$i) {
-            $char = (int) $input[$i];
-            $sindex = $last - $this->_sbase;
-            $lindex = $last - $this->_lbase;
-            $vindex = $char - $this->_vbase;
-            $tindex = $char - $this->_tbase;
-            // Find out, whether two current characters are LV and T
-            if (0 <= $sindex && $sindex < $this->_scount && ($sindex % $this->_tcount == 0)
-                    && 0 <= $tindex && $tindex <= $this->_tcount) {
-                // create syllable of form LVT
-                $last += $tindex;
-                $result[(count($result) - 1)] = $last; // reset last
-                continue; // discard char
-            }
-            // Find out, whether two current characters form L and V
-            if (0 <= $lindex && $lindex < $this->_lcount && 0 <= $vindex && $vindex < $this->_vcount) {
-                // create syllable of form LV
-                $last = (int) $this->_sbase + ($lindex * $this->_vcount + $vindex) * $this->_tcount;
-                $result[(count($result) - 1)] = $last; // reset last
-                continue; // discard char
-            }
-            // if neither case was true, just add the character
-            $last = $char;
-            $result[] = $char;
-        }
-        return $result;
-    }
-
-    /**
-     * Returns the combining class of a certain wide char
-     * @param    integer    Wide char to check (32bit integer)
-     * @return   integer    Combining class if found, else 0
-     */
-    private function _get_combining_class($char)
-    {
-        return isset($this->NP['norm_combcls'][$char]) ? $this->NP['norm_combcls'][$char] : 0;
-    }
-
-    /**
-     * Apllies the cannonical ordering of a decomposed UCS4 sequence
-     * @param    array      Decomposed UCS4 sequence
-     * @return   array      Ordered USC4 sequence
-     */
-    private function _apply_cannonical_ordering($input)
-    {
-        $swap = true;
-        $size = count($input);
-        while ($swap) {
-            $swap = false;
-            $last = $this->_get_combining_class(intval($input[0]));
-            for ($i = 0; $i < $size-1; ++$i) {
-                $next = $this->_get_combining_class(intval($input[$i+1]));
-                if ($next != 0 && $last > $next) {
-                    // Move item leftward until it fits
-                    for ($j = $i + 1; $j > 0; --$j) {
-                        if ($this->_get_combining_class(intval($input[$j-1])) <= $next) break;
-                        $t = intval($input[$j]);
-                        $input[$j] = intval($input[$j-1]);
-                        $input[$j-1] = $t;
-                        $swap = true;
-                    }
-                    // Reentering the loop looking at the old character again
-                    $next = $last;
-                }
-                $last = $next;
-            }
-        }
-        return $input;
-    }
-
-    /**
-     * Do composition of a sequence of starter and non-starter
-     * @param    array      UCS4 Decomposed sequence
-     * @return   array      Ordered USC4 sequence
-     */
-    private function _combine($input)
-    {
-        $inp_len = count($input);
-        foreach ($this->NP['replacemaps'] as $np_src => $np_target) {
-            if ($np_target[0] != $input[0]) continue;
-            if (count($np_target) != $inp_len) continue;
-            $hit = false;
-            foreach ($input as $k2 => $v2) {
-                if ($v2 == $np_target[$k2]) {
-                    $hit = true;
-                } else {
-                    $hit = false;
-                    break;
-                }
-            }
-            if ($hit) return $np_src;
-        }
-        return false;
-    }
-
-    /**
-     * This converts an UTF-8 encoded string to its UCS-4 representation
-     * By talking about UCS-4 "strings" we mean arrays of 32bit integers representing
-     * each of the "chars". This is due to PHP not being able to handle strings with
-     * bit depth different from 8. This apllies to the reverse method _ucs4_to_utf8(), too.
-     * The following UTF-8 encodings are supported:
-     * bytes bits  representation
-     * 1        7  0xxxxxxx
-     * 2       11  110xxxxx 10xxxxxx
-     * 3       16  1110xxxx 10xxxxxx 10xxxxxx
-     * 4       21  11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
-     * 5       26  111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
-     * 6       31  1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
-     * Each x represents a bit that can be used to store character data.
-     * The five and six byte sequences are part of Annex D of ISO/IEC 10646-1:2000
-     * @param string $input
-     * @return string
-     */
-    private function _utf8_to_ucs4($input)
-    {
-        $output = array();
-        $out_len = 0;
-        $inp_len = strlen($input);
-        $mode = 'next';
-        $test = 'none';
-        for ($k = 0; $k < $inp_len; ++$k) {
-            $v = ord($input{$k}); // Extract byte from input string
-            if ($v < 128) { // We found an ASCII char - put into stirng as is
-                $output[$out_len] = $v;
-                ++$out_len;
-                if ('add' == $mode) {
-                    $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
-                    return false;
-                }
-                continue;
-            }
-            if ('next' == $mode) { // Try to find the next start byte; determine the width of the Unicode char
-                $start_byte = $v;
-                $mode = 'add';
-                $test = 'range';
-                if ($v >> 5 == 6) { // &110xxxxx 10xxxxx
-                    $next_byte = 0; // Tells, how many times subsequent bitmasks must rotate 6bits to the left
-                    $v = ($v - 192) << 6;
-                } elseif ($v >> 4 == 14) { // &1110xxxx 10xxxxxx 10xxxxxx
-                    $next_byte = 1;
-                    $v = ($v - 224) << 12;
-                } elseif ($v >> 3 == 30) { // &11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
-                    $next_byte = 2;
-                    $v = ($v - 240) << 18;
-                } elseif ($v >> 2 == 62) { // &111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
-                    $next_byte = 3;
-                    $v = ($v - 248) << 24;
-                } elseif ($v >> 1 == 126) { // &1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
-                    $next_byte = 4;
-                    $v = ($v - 252) << 30;
-                } else {
-                    $this->_error('This might be UTF-8, but I don\'t understand it at byte '.$k);
-                    return false;
-                }
-                if ('add' == $mode) {
-                    $output[$out_len] = (int) $v;
-                    ++$out_len;
-                    continue;
-                }
-            }
-            if ('add' == $mode) {
-                if (!$this->_allow_overlong && $test == 'range') {
-                    $test = 'none';
-                    if (($v < 0xA0 && $start_byte == 0xE0) || ($v < 0x90 && $start_byte == 0xF0) || ($v > 0x8F && $start_byte == 0xF4)) {
-                        $this->_error('Bogus UTF-8 character detected (out of legal range) at byte '.$k);
-                        return false;
-                    }
-                }
-                if ($v >> 6 == 2) { // Bit mask must be 10xxxxxx
-                    $v = ($v - 128) << ($next_byte * 6);
-                    $output[($out_len - 1)] += $v;
-                    --$next_byte;
-                } else {
-                    $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
-                    return false;
-                }
-                if ($next_byte < 0) {
-                    $mode = 'next';
-                }
-            }
-        } // for
-        return $output;
-    }
-
-    /**
-     * Convert UCS-4 string into UTF-8 string
-     * See _utf8_to_ucs4() for details
-     * @param string  $input
-     * @return string
-     */
-    private function _ucs4_to_utf8($input)
-    {
-        $output = '';
-        foreach ($input as $v) {
-            if ($v < 128) { // 7bit are transferred literally
-                $output .= chr($v);
-            } elseif ($v < (1 << 11)) { // 2 bytes
-                $output .= chr(192+($v >> 6)).chr(128+($v & 63));
-            } elseif ($v < (1 << 16)) { // 3 bytes
-                $output .= chr(224+($v >> 12)).chr(128+(($v >> 6) & 63)).chr(128+($v & 63));
-            } elseif ($v < (1 << 21)) { // 4 bytes
-                $output .= chr(240+($v >> 18)).chr(128+(($v >> 12) & 63)).chr(128+(($v >> 6) & 63)).chr(128+($v & 63));
-            } elseif (self::$safe_mode) {
-                $output .= self::$safe_char;
-            } else {
-                $this->_error('Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k);
-                return false;
-            }
-        }
-        return $output;
-    }
-
-    /**
-      * Convert UCS-4 array into UCS-4 string
-      *
-      * @param array $input
-      * @return string
-      */
-    private function _ucs4_to_ucs4_string($input)
-    {
-        $output = '';
-        // Take array values and split output to 4 bytes per value
-        // The bit mask is 255, which reads &11111111
-        foreach ($input as $v) {
-            $output .= chr(($v >> 24) & 255).chr(($v >> 16) & 255).chr(($v >> 8) & 255).chr($v & 255);
-        }
-        return $output;
-    }
-
-    /**
-      * Convert UCS-4 strin into UCS-4 garray
-      *
-      * @param  string $input
-      * @return array
-      */
-    private function _ucs4_string_to_ucs4($input)
-    {
-        $output = array();
-        $inp_len = strlen($input);
-        // Input length must be dividable by 4
-        if ($inp_len % 4) {
-            $this->_error('Input UCS4 string is broken');
-            return false;
-        }
-        // Empty input - return empty output
-        if (!$inp_len) return $output;
-        for ($i = 0, $out_len = -1; $i < $inp_len; ++$i) {
-            // Increment output position every 4 input bytes
-            if (!($i % 4)) {
-                $out_len++;
-                $output[$out_len] = 0;
-            }
-            $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) );
-        }
-        return $output;
-    }
-
-    /**
-     * Holds all relevant mapping tables, loaded from a seperate file on construct
-     * See RFC3454 for details
-     *
-     * @private array
-     * @since 0.5.2
-     *
-     */
-    private $NP = array
-            ('map_nothing' => array
-                    (0xAD, 0x34F, 0x1806, 0x180B, 0x180C, 0x180D, 0x200B
-                    ,0x200C, 0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03
-                    ,0xFE04, 0xFE05, 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A
-                    ,0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E, 0xFE0F, 0xFEFF
-                    )
-            ,'general_prohibited' => array
-                    (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE
-                    ,0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17
-                    ,0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20
-                    ,0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29
-                    ,0x2A, 0x2B, 0x2C, 0x2F, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F
-                    ,0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x7B, 0x7C
-                    ,0x7D, 0x7E, 0x7F, 0x3002
-                    )
-            ,'prohibit' => array
-                    (0xA0, 0x340, 0x341, 0x6DD, 0x70F, 0x1680, 0x180E, 0x2000
-                    ,0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007
-                    ,0x2008, 0x2009, 0x200A, 0x200B, 0x200C, 0x200D, 0x200E
-                    ,0x200F, 0x2028, 0x2029, 0x202A, 0x202B, 0x202C, 0x202D
-                    ,0x202E, 0x202F, 0x205F, 0x206A, 0x206B, 0x206C, 0x206D
-                    ,0x206E, 0x206F, 0x3000, 0xFEFF, 0xFFF9, 0xFFFA, 0xFFFB
-                    ,0xFFFC, 0xFFFD, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF, 0x2FFFE
-                    ,0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE
-                    ,0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE
-                    ,0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE
-                    ,0xBFFFF, 0xCFFFE, 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xE0001
-                    ,0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF, 0x10FFFE, 0x10FFFF
-                    )
-            ,'prohibit_ranges' => array
-                    (array(0x80, 0x9F), array(0x2060, 0x206F)
-                    ,array(0x1D173, 0x1D17A), array(0xE000, 0xF8FF)
-                    ,array(0xF0000, 0xFFFFD), array(0x100000, 0x10FFFD)
-                    ,array(0xFDD0, 0xFDEF), array(0xD800, 0xDFFF)
-                    ,array(0x2FF0, 0x2FFB), array(0xE0020, 0xE007F)
-                    )
-            ,'replacemaps' => array
-                    (0x41 => array(0x61)
-                    ,0x42 => array(0x62)
-                    ,0x43 => array(0x63)
-                    ,0x44 => array(0x64)
-                    ,0x45 => array(0x65)
-                    ,0x46 => array(0x66)
-                    ,0x47 => array(0x67)
-                    ,0x48 => array(0x68)
-                    ,0x49 => array(0x69)
-                    ,0x4A => array(0x6A)
-                    ,0x4B => array(0x6B)
-                    ,0x4C => array(0x6C)
-                    ,0x4D => array(0x6D)
-                    ,0x4E => array(0x6E)
-                    ,0x4F => array(0x6F)
-                    ,0x50 => array(0x70)
-                    ,0x51 => array(0x71)
-                    ,0x52 => array(0x72)
-                    ,0x53 => array(0x73)
-                    ,0x54 => array(0x74)
-                    ,0x55 => array(0x75)
-                    ,0x56 => array(0x76)
-                    ,0x57 => array(0x77)
-                    ,0x58 => array(0x78)
-                    ,0x59 => array(0x79)
-                    ,0x5A => array(0x7A)
-                    ,0xB5 => array(0x3BC)
-                    ,0xC0 => array(0xE0)
-                    ,0xC1 => array(0xE1)
-                    ,0xC2 => array(0xE2)
-                    ,0xC3 => array(0xE3)
-                    ,0xC4 => array(0xE4)
-                    ,0xC5 => array(0xE5)
-                    ,0xC6 => array(0xE6)
-                    ,0xC7 => array(0xE7)
-                    ,0xC8 => array(0xE8)
-                    ,0xC9 => array(0xE9)
-                    ,0xCA => array(0xEA)
-                    ,0xCB => array(0xEB)
-                    ,0xCC => array(0xEC)
-                    ,0xCD => array(0xED)
-                    ,0xCE => array(0xEE)
-                    ,0xCF => array(0xEF)
-                    ,0xD0 => array(0xF0)
-                    ,0xD1 => array(0xF1)
-                    ,0xD2 => array(0xF2)
-                    ,0xD3 => array(0xF3)
-                    ,0xD4 => array(0xF4)
-                    ,0xD5 => array(0xF5)
-                    ,0xD6 => array(0xF6)
-                    ,0xD8 => array(0xF8)
-                    ,0xD9 => array(0xF9)
-                    ,0xDA => array(0xFA)
-                    ,0xDB => array(0xFB)
-                    ,0xDC => array(0xFC)
-                    ,0xDD => array(0xFD)
-                    ,0xDE => array(0xFE)
-                    ,0xDF => array(0x73, 0x73)
-                    ,0x100 => array(0x101)
-                    ,0x102 => array(0x103)
-                    ,0x104 => array(0x105)
-                    ,0x106 => array(0x107)
-                    ,0x108 => array(0x109)
-                    ,0x10A => array(0x10B)
-                    ,0x10C => array(0x10D)
-                    ,0x10E => array(0x10F)
-                    ,0x110 => array(0x111)
-                    ,0x112 => array(0x113)
-                    ,0x114 => array(0x115)
-                    ,0x116 => array(0x117)
-                    ,0x118 => array(0x119)
-                    ,0x11A => array(0x11B)
-                    ,0x11C => array(0x11D)
-                    ,0x11E => array(0x11F)
-                    ,0x120 => array(0x121)
-                    ,0x122 => array(0x123)
-                    ,0x124 => array(0x125)
-                    ,0x126 => array(0x127)
-                    ,0x128 => array(0x129)
-                    ,0x12A => array(0x12B)
-                    ,0x12C => array(0x12D)
-                    ,0x12E => array(0x12F)
-                    ,0x130 => array(0x69, 0x307)
-                    ,0x132 => array(0x133)
-                    ,0x134 => array(0x135)
-                    ,0x136 => array(0x137)
-                    ,0x139 => array(0x13A)
-                    ,0x13B => array(0x13C)
-                    ,0x13D => array(0x13E)
-                    ,0x13F => array(0x140)
-                    ,0x141 => array(0x142)
-                    ,0x143 => array(0x144)
-                    ,0x145 => array(0x146)
-                    ,0x147 => array(0x148)
-                    ,0x149 => array(0x2BC, 0x6E)
-                    ,0x14A => array(0x14B)
-                    ,0x14C => array(0x14D)
-                    ,0x14E => array(0x14F)
-                    ,0x150 => array(0x151)
-                    ,0x152 => array(0x153)
-                    ,0x154 => array(0x155)
-                    ,0x156 => array(0x157)
-                    ,0x158 => array(0x159)
-                    ,0x15A => array(0x15B)
-                    ,0x15C => array(0x15D)
-                    ,0x15E => array(0x15F)
-                    ,0x160 => array(0x161)
-                    ,0x162 => array(0x163)
-                    ,0x164 => array(0x165)
-                    ,0x166 => array(0x167)
-                    ,0x168 => array(0x169)
-                    ,0x16A => array(0x16B)
-                    ,0x16C => array(0x16D)
-                    ,0x16E => array(0x16F)
-                    ,0x170 => array(0x171)
-                    ,0x172 => array(0x173)
-                    ,0x174 => array(0x175)
-                    ,0x176 => array(0x177)
-                    ,0x178 => array(0xFF)
-                    ,0x179 => array(0x17A)
-                    ,0x17B => array(0x17C)
-                    ,0x17D => array(0x17E)
-                    ,0x17F => array(0x73)
-                    ,0x181 => array(0x253)
-                    ,0x182 => array(0x183)
-                    ,0x184 => array(0x185)
-                    ,0x186 => array(0x254)
-                    ,0x187 => array(0x188)
-                    ,0x189 => array(0x256)
-                    ,0x18A => array(0x257)
-                    ,0x18B => array(0x18C)
-                    ,0x18E => array(0x1DD)
-                    ,0x18F => array(0x259)
-                    ,0x190 => array(0x25B)
-                    ,0x191 => array(0x192)
-                    ,0x193 => array(0x260)
-                    ,0x194 => array(0x263)
-                    ,0x196 => array(0x269)
-                    ,0x197 => array(0x268)
-                    ,0x198 => array(0x199)
-                    ,0x19C => array(0x26F)
-                    ,0x19D => array(0x272)
-                    ,0x19F => array(0x275)
-                    ,0x1A0 => array(0x1A1)
-                    ,0x1A2 => array(0x1A3)
-                    ,0x1A4 => array(0x1A5)
-                    ,0x1A6 => array(0x280)
-                    ,0x1A7 => array(0x1A8)
-                    ,0x1A9 => array(0x283)
-                    ,0x1AC => array(0x1AD)
-                    ,0x1AE => array(0x288)
-                    ,0x1AF => array(0x1B0)
-                    ,0x1B1 => array(0x28A)
-                    ,0x1B2 => array(0x28B)
-                    ,0x1B3 => array(0x1B4)
-                    ,0x1B5 => array(0x1B6)
-                    ,0x1B7 => array(0x292)
-                    ,0x1B8 => array(0x1B9)
-                    ,0x1BC => array(0x1BD)
-                    ,0x1C4 => array(0x1C6)
-                    ,0x1C5 => array(0x1C6)
-                    ,0x1C7 => array(0x1C9)
-                    ,0x1C8 => array(0x1C9)
-                    ,0x1CA => array(0x1CC)
-                    ,0x1CB => array(0x1CC)
-                    ,0x1CD => array(0x1CE)
-                    ,0x1CF => array(0x1D0)
-                    ,0x1D1   => array(0x1D2)
-                    ,0x1D3   => array(0x1D4)
-                    ,0x1D5   => array(0x1D6)
-                    ,0x1D7   => array(0x1D8)
-                    ,0x1D9   => array(0x1DA)
-                    ,0x1DB   => array(0x1DC)
-                    ,0x1DE   => array(0x1DF)
-                    ,0x1E0   => array(0x1E1)
-                    ,0x1E2   => array(0x1E3)
-                    ,0x1E4   => array(0x1E5)
-                    ,0x1E6   => array(0x1E7)
-                    ,0x1E8   => array(0x1E9)
-                    ,0x1EA   => array(0x1EB)
-                    ,0x1EC   => array(0x1ED)
-                    ,0x1EE   => array(0x1EF)
-                    ,0x1F0   => array(0x6A, 0x30C)
-                    ,0x1F1   => array(0x1F3)
-                    ,0x1F2   => array(0x1F3)
-                    ,0x1F4   => array(0x1F5)
-                    ,0x1F6   => array(0x195)
-                    ,0x1F7   => array(0x1BF)
-                    ,0x1F8   => array(0x1F9)
-                    ,0x1FA   => array(0x1FB)
-                    ,0x1FC   => array(0x1FD)
-                    ,0x1FE   => array(0x1FF)
-                    ,0x200   => array(0x201)
-                    ,0x202   => array(0x203)
-                    ,0x204   => array(0x205)
-                    ,0x206   => array(0x207)
-                    ,0x208   => array(0x209)
-                    ,0x20A   => array(0x20B)
-                    ,0x20C   => array(0x20D)
-                    ,0x20E   => array(0x20F)
-                    ,0x210   => array(0x211)
-                    ,0x212   => array(0x213)
-                    ,0x214   => array(0x215)
-                    ,0x216   => array(0x217)
-                    ,0x218   => array(0x219)
-                    ,0x21A   => array(0x21B)
-                    ,0x21C   => array(0x21D)
-                    ,0x21E   => array(0x21F)
-                    ,0x220   => array(0x19E)
-                    ,0x222   => array(0x223)
-                    ,0x224   => array(0x225)
-                    ,0x226   => array(0x227)
-                    ,0x228   => array(0x229)
-                    ,0x22A   => array(0x22B)
-                    ,0x22C   => array(0x22D)
-                    ,0x22E   => array(0x22F)
-                    ,0x230   => array(0x231)
-                    ,0x232   => array(0x233)
-                    ,0x345   => array(0x3B9)
-                    ,0x37A   => array(0x20, 0x3B9)
-                    ,0x386   => array(0x3AC)
-                    ,0x388   => array(0x3AD)
-                    ,0x389   => array(0x3AE)
-                    ,0x38A   => array(0x3AF)
-                    ,0x38C   => array(0x3CC)
-                    ,0x38E   => array(0x3CD)
-                    ,0x38F   => array(0x3CE)
-                    ,0x390   => array(0x3B9, 0x308, 0x301)
-                    ,0x391   => array(0x3B1)
-                    ,0x392   => array(0x3B2)
-                    ,0x393   => array(0x3B3)
-                    ,0x394   => array(0x3B4)
-                    ,0x395   => array(0x3B5)
-                    ,0x396   => array(0x3B6)
-                    ,0x397   => array(0x3B7)
-                    ,0x398   => array(0x3B8)
-                    ,0x399   => array(0x3B9)
-                    ,0x39A   => array(0x3BA)
-                    ,0x39B   => array(0x3BB)
-                    ,0x39C   => array(0x3BC)
-                    ,0x39D   => array(0x3BD)
-                    ,0x39E   => array(0x3BE)
-                    ,0x39F   => array(0x3BF)
-                    ,0x3A0   => array(0x3C0)
-                    ,0x3A1   => array(0x3C1)
-                    ,0x3A3   => array(0x3C3)
-                    ,0x3A4   => array(0x3C4)
-                    ,0x3A5   => array(0x3C5)
-                    ,0x3A6   => array(0x3C6)
-                    ,0x3A7   => array(0x3C7)
-                    ,0x3A8   => array(0x3C8)
-                    ,0x3A9   => array(0x3C9)
-                    ,0x3AA   => array(0x3CA)
-                    ,0x3AB   => array(0x3CB)
-                    ,0x3B0   => array(0x3C5, 0x308, 0x301)
-                    ,0x3C2   => array(0x3C3)
-                    ,0x3D0   => array(0x3B2)
-                    ,0x3D1   => array(0x3B8)
-                    ,0x3D2   => array(0x3C5)
-                    ,0x3D3   => array(0x3CD)
-                    ,0x3D4   => array(0x3CB)
-                    ,0x3D5   => array(0x3C6)
-                    ,0x3D6   => array(0x3C0)
-                    ,0x3D8   => array(0x3D9)
-                    ,0x3DA   => array(0x3DB)
-                    ,0x3DC   => array(0x3DD)
-                    ,0x3DE   => array(0x3DF)
-                    ,0x3E0   => array(0x3E1)
-                    ,0x3E2   => array(0x3E3)
-                    ,0x3E4   => array(0x3E5)
-                    ,0x3E6   => array(0x3E7)
-                    ,0x3E8   => array(0x3E9)
-                    ,0x3EA   => array(0x3EB)
-                    ,0x3EC   => array(0x3ED)
-                    ,0x3EE   => array(0x3EF)
-                    ,0x3F0   => array(0x3BA)
-                    ,0x3F1   => array(0x3C1)
-                    ,0x3F2   => array(0x3C3)
-                    ,0x3F4   => array(0x3B8)
-                    ,0x3F5   => array(0x3B5)
-                    ,0x400   => array(0x450)
-                    ,0x401   => array(0x451)
-                    ,0x402   => array(0x452)
-                    ,0x403   => array(0x453)
-                    ,0x404   => array(0x454)
-                    ,0x405   => array(0x455)
-                    ,0x406   => array(0x456)
-                    ,0x407   => array(0x457)
-                    ,0x408   => array(0x458)
-                    ,0x409   => array(0x459)
-                    ,0x40A   => array(0x45A)
-                    ,0x40B   => array(0x45B)
-                    ,0x40C   => array(0x45C)
-                    ,0x40D   => array(0x45D)
-                    ,0x40E   => array(0x45E)
-                    ,0x40F   => array(0x45F)
-                    ,0x410   => array(0x430)
-                    ,0x411   => array(0x431)
-                    ,0x412   => array(0x432)
-                    ,0x413   => array(0x433)
-                    ,0x414   => array(0x434)
-                    ,0x415   => array(0x435)
-                    ,0x416   => array(0x436)
-                    ,0x417   => array(0x437)
-                    ,0x418   => array(0x438)
-                    ,0x419   => array(0x439)
-                    ,0x41A   => array(0x43A)
-                    ,0x41B   => array(0x43B)
-                    ,0x41C   => array(0x43C)
-                    ,0x41D   => array(0x43D)
-                    ,0x41E   => array(0x43E)
-                    ,0x41F   => array(0x43F)
-                    ,0x420   => array(0x440)
-                    ,0x421   => array(0x441)
-                    ,0x422   => array(0x442)
-                    ,0x423   => array(0x443)
-                    ,0x424   => array(0x444)
-                    ,0x425   => array(0x445)
-                    ,0x426   => array(0x446)
-                    ,0x427   => array(0x447)
-                    ,0x428   => array(0x448)
-                    ,0x429   => array(0x449)
-                    ,0x42A   => array(0x44A)
-                    ,0x42B   => array(0x44B)
-                    ,0x42C   => array(0x44C)
-                    ,0x42D   => array(0x44D)
-                    ,0x42E   => array(0x44E)
-                    ,0x42F   => array(0x44F)
-                    ,0x460   => array(0x461)
-                    ,0x462   => array(0x463)
-                    ,0x464   => array(0x465)
-                    ,0x466   => array(0x467)
-                    ,0x468   => array(0x469)
-                    ,0x46A   => array(0x46B)
-                    ,0x46C   => array(0x46D)
-                    ,0x46E   => array(0x46F)
-                    ,0x470   => array(0x471)
-                    ,0x472   => array(0x473)
-                    ,0x474   => array(0x475)
-                    ,0x476   => array(0x477)
-                    ,0x478   => array(0x479)
-                    ,0x47A   => array(0x47B)
-                    ,0x47C   => array(0x47D)
-                    ,0x47E   => array(0x47F)
-                    ,0x480   => array(0x481)
-                    ,0x48A   => array(0x48B)
-                    ,0x48C   => array(0x48D)
-                    ,0x48E   => array(0x48F)
-                    ,0x490   => array(0x491)
-                    ,0x492   => array(0x493)
-                    ,0x494   => array(0x495)
-                    ,0x496   => array(0x497)
-                    ,0x498   => array(0x499)
-                    ,0x49A   => array(0x49B)
-                    ,0x49C   => array(0x49D)
-                    ,0x49E   => array(0x49F)
-                    ,0x4A0   => array(0x4A1)
-                    ,0x4A2   => array(0x4A3)
-                    ,0x4A4   => array(0x4A5)
-                    ,0x4A6   => array(0x4A7)
-                    ,0x4A8   => array(0x4A9)
-                    ,0x4AA   => array(0x4AB)
-                    ,0x4AC   => array(0x4AD)
-                    ,0x4AE   => array(0x4AF)
-                    ,0x4B0   => array(0x4B1)
-                    ,0x4B2   => array(0x4B3)
-                    ,0x4B4   => array(0x4B5)
-                    ,0x4B6   => array(0x4B7)
-                    ,0x4B8   => array(0x4B9)
-                    ,0x4BA   => array(0x4BB)
-                    ,0x4BC   => array(0x4BD)
-                    ,0x4BE   => array(0x4BF)
-                    ,0x4C1   => array(0x4C2)
-                    ,0x4C3   => array(0x4C4)
-                    ,0x4C5   => array(0x4C6)
-                    ,0x4C7   => array(0x4C8)
-                    ,0x4C9   => array(0x4CA)
-                    ,0x4CB   => array(0x4CC)
-                    ,0x4CD   => array(0x4CE)
-                    ,0x4D0   => array(0x4D1)
-                    ,0x4D2   => array(0x4D3)
-                    ,0x4D4   => array(0x4D5)
-                    ,0x4D6   => array(0x4D7)
-                    ,0x4D8   => array(0x4D9)
-                    ,0x4DA   => array(0x4DB)
-                    ,0x4DC   => array(0x4DD)
-                    ,0x4DE   => array(0x4DF)
-                    ,0x4E0   => array(0x4E1)
-                    ,0x4E2   => array(0x4E3)
-                    ,0x4E4   => array(0x4E5)
-                    ,0x4E6   => array(0x4E7)
-                    ,0x4E8   => array(0x4E9)
-                    ,0x4EA   => array(0x4EB)
-                    ,0x4EC   => array(0x4ED)
-                    ,0x4EE   => array(0x4EF)
-                    ,0x4F0   => array(0x4F1)
-                    ,0x4F2   => array(0x4F3)
-                    ,0x4F4   => array(0x4F5)
-                    ,0x4F8   => array(0x4F9)
-                    ,0x500   => array(0x501)
-                    ,0x502   => array(0x503)
-                    ,0x504   => array(0x505)
-                    ,0x506   => array(0x507)
-                    ,0x508   => array(0x509)
-                    ,0x50A   => array(0x50B)
-                    ,0x50C   => array(0x50D)
-                    ,0x50E   => array(0x50F)
-                    ,0x531   => array(0x561)
-                    ,0x532   => array(0x562)
-                    ,0x533   => array(0x563)
-                    ,0x534   => array(0x564)
-                    ,0x535   => array(0x565)
-                    ,0x536   => array(0x566)
-                    ,0x537   => array(0x567)
-                    ,0x538   => array(0x568)
-                    ,0x539   => array(0x569)
-                    ,0x53A   => array(0x56A)
-                    ,0x53B   => array(0x56B)
-                    ,0x53C   => array(0x56C)
-                    ,0x53D   => array(0x56D)
-                    ,0x53E   => array(0x56E)
-                    ,0x53F   => array(0x56F)
-                    ,0x540   => array(0x570)
-                    ,0x541   => array(0x571)
-                    ,0x542   => array(0x572)
-                    ,0x543   => array(0x573)
-                    ,0x544   => array(0x574)
-                    ,0x545   => array(0x575)
-                    ,0x546   => array(0x576)
-                    ,0x547   => array(0x577)
-                    ,0x548   => array(0x578)
-                    ,0x549   => array(0x579)
-                    ,0x54A   => array(0x57A)
-                    ,0x54B   => array(0x57B)
-                    ,0x54C   => array(0x57C)
-                    ,0x54D   => array(0x57D)
-                    ,0x54E   => array(0x57E)
-                    ,0x54F   => array(0x57F)
-                    ,0x550   => array(0x580)
-                    ,0x551   => array(0x581)
-                    ,0x552   => array(0x582)
-                    ,0x553   => array(0x583)
-                    ,0x554   => array(0x584)
-                    ,0x555   => array(0x585)
-                    ,0x556   => array(0x586)
-                    ,0x587   => array(0x565, 0x582)
-                    ,0x1E00  => array(0x1E01)
-                    ,0x1E02  => array(0x1E03)
-                    ,0x1E04  => array(0x1E05)
-                    ,0x1E06  => array(0x1E07)
-                    ,0x1E08  => array(0x1E09)
-                    ,0x1E0A  => array(0x1E0B)
-                    ,0x1E0C  => array(0x1E0D)
-                    ,0x1E0E  => array(0x1E0F)
-                    ,0x1E10  => array(0x1E11)
-                    ,0x1E12  => array(0x1E13)
-                    ,0x1E14  => array(0x1E15)
-                    ,0x1E16  => array(0x1E17)
-                    ,0x1E18  => array(0x1E19)
-                    ,0x1E1A  => array(0x1E1B)
-                    ,0x1E1C  => array(0x1E1D)
-                    ,0x1E1E  => array(0x1E1F)
-                    ,0x1E20  => array(0x1E21)
-                    ,0x1E22  => array(0x1E23)
-                    ,0x1E24  => array(0x1E25)
-                    ,0x1E26  => array(0x1E27)
-                    ,0x1E28  => array(0x1E29)
-                    ,0x1E2A  => array(0x1E2B)
-                    ,0x1E2C  => array(0x1E2D)
-                    ,0x1E2E  => array(0x1E2F)
-                    ,0x1E30  => array(0x1E31)
-                    ,0x1E32  => array(0x1E33)
-                    ,0x1E34  => array(0x1E35)
-                    ,0x1E36  => array(0x1E37)
-                    ,0x1E38  => array(0x1E39)
-                    ,0x1E3A  => array(0x1E3B)
-                    ,0x1E3C  => array(0x1E3D)
-                    ,0x1E3E  => array(0x1E3F)
-                    ,0x1E40  => array(0x1E41)
-                    ,0x1E42  => array(0x1E43)
-                    ,0x1E44  => array(0x1E45)
-                    ,0x1E46  => array(0x1E47)
-                    ,0x1E48  => array(0x1E49)
-                    ,0x1E4A  => array(0x1E4B)
-                    ,0x1E4C  => array(0x1E4D)
-                    ,0x1E4E  => array(0x1E4F)
-                    ,0x1E50  => array(0x1E51)
-                    ,0x1E52  => array(0x1E53)
-                    ,0x1E54  => array(0x1E55)
-                    ,0x1E56  => array(0x1E57)
-                    ,0x1E58  => array(0x1E59)
-                    ,0x1E5A  => array(0x1E5B)
-                    ,0x1E5C  => array(0x1E5D)
-                    ,0x1E5E  => array(0x1E5F)
-                    ,0x1E60  => array(0x1E61)
-                    ,0x1E62  => array(0x1E63)
-                    ,0x1E64  => array(0x1E65)
-                    ,0x1E66  => array(0x1E67)
-                    ,0x1E68  => array(0x1E69)
-                    ,0x1E6A  => array(0x1E6B)
-                    ,0x1E6C  => array(0x1E6D)
-                    ,0x1E6E  => array(0x1E6F)
-                    ,0x1E70  => array(0x1E71)
-                    ,0x1E72  => array(0x1E73)
-                    ,0x1E74  => array(0x1E75)
-                    ,0x1E76  => array(0x1E77)
-                    ,0x1E78  => array(0x1E79)
-                    ,0x1E7A  => array(0x1E7B)
-                    ,0x1E7C  => array(0x1E7D)
-                    ,0x1E7E  => array(0x1E7F)
-                    ,0x1E80  => array(0x1E81)
-                    ,0x1E82  => array(0x1E83)
-                    ,0x1E84  => array(0x1E85)
-                    ,0x1E86  => array(0x1E87)
-                    ,0x1E88  => array(0x1E89)
-                    ,0x1E8A  => array(0x1E8B)
-                    ,0x1E8C  => array(0x1E8D)
-                    ,0x1E8E  => array(0x1E8F)
-                    ,0x1E90  => array(0x1E91)
-                    ,0x1E92  => array(0x1E93)
-                    ,0x1E94  => array(0x1E95)
-                    ,0x1E96  => array(0x68, 0x331)
-                    ,0x1E97  => array(0x74, 0x308)
-                    ,0x1E98  => array(0x77, 0x30A)
-                    ,0x1E99  => array(0x79, 0x30A)
-                    ,0x1E9A  => array(0x61, 0x2BE)
-                    ,0x1E9B  => array(0x1E61)
-                    ,0x1EA0  => array(0x1EA1)
-                    ,0x1EA2  => array(0x1EA3)
-                    ,0x1EA4  => array(0x1EA5)
-                    ,0x1EA6  => array(0x1EA7)
-                    ,0x1EA8  => array(0x1EA9)
-                    ,0x1EAA  => array(0x1EAB)
-                    ,0x1EAC  => array(0x1EAD)
-                    ,0x1EAE  => array(0x1EAF)
-                    ,0x1EB0  => array(0x1EB1)
-                    ,0x1EB2  => array(0x1EB3)
-                    ,0x1EB4  => array(0x1EB5)
-                    ,0x1EB6  => array(0x1EB7)
-                    ,0x1EB8  => array(0x1EB9)
-                    ,0x1EBA  => array(0x1EBB)
-                    ,0x1EBC  => array(0x1EBD)
-                    ,0x1EBE  => array(0x1EBF)
-                    ,0x1EC0  => array(0x1EC1)
-                    ,0x1EC2  => array(0x1EC3)
-                    ,0x1EC4  => array(0x1EC5)
-                    ,0x1EC6  => array(0x1EC7)
-                    ,0x1EC8  => array(0x1EC9)
-                    ,0x1ECA  => array(0x1ECB)
-                    ,0x1ECC  => array(0x1ECD)
-                    ,0x1ECE  => array(0x1ECF)
-                    ,0x1ED0  => array(0x1ED1)
-                    ,0x1ED2  => array(0x1ED3)
-                    ,0x1ED4  => array(0x1ED5)
-                    ,0x1ED6  => array(0x1ED7)
-                    ,0x1ED8  => array(0x1ED9)
-                    ,0x1EDA  => array(0x1EDB)
-                    ,0x1EDC  => array(0x1EDD)
-                    ,0x1EDE  => array(0x1EDF)
-                    ,0x1EE0  => array(0x1EE1)
-                    ,0x1EE2  => array(0x1EE3)
-                    ,0x1EE4  => array(0x1EE5)
-                    ,0x1EE6  => array(0x1EE7)
-                    ,0x1EE8  => array(0x1EE9)
-                    ,0x1EEA  => array(0x1EEB)
-                    ,0x1EEC  => array(0x1EED)
-                    ,0x1EEE  => array(0x1EEF)
-                    ,0x1EF0  => array(0x1EF1)
-                    ,0x1EF2  => array(0x1EF3)
-                    ,0x1EF4  => array(0x1EF5)
-                    ,0x1EF6  => array(0x1EF7)
-                    ,0x1EF8  => array(0x1EF9)
-                    ,0x1F08  => array(0x1F00)
-                    ,0x1F09  => array(0x1F01)
-                    ,0x1F0A  => array(0x1F02)
-                    ,0x1F0B  => array(0x1F03)
-                    ,0x1F0C  => array(0x1F04)
-                    ,0x1F0D  => array(0x1F05)
-                    ,0x1F0E  => array(0x1F06)
-                    ,0x1F0F  => array(0x1F07)
-                    ,0x1F18  => array(0x1F10)
-                    ,0x1F19  => array(0x1F11)
-                    ,0x1F1A  => array(0x1F12)
-                    ,0x1F1B  => array(0x1F13)
-                    ,0x1F1C  => array(0x1F14)
-                    ,0x1F1D  => array(0x1F15)
-                    ,0x1F28  => array(0x1F20)
-                    ,0x1F29  => array(0x1F21)
-                    ,0x1F2A  => array(0x1F22)
-                    ,0x1F2B  => array(0x1F23)
-                    ,0x1F2C  => array(0x1F24)
-                    ,0x1F2D  => array(0x1F25)
-                    ,0x1F2E  => array(0x1F26)
-                    ,0x1F2F  => array(0x1F27)
-                    ,0x1F38  => array(0x1F30)
-                    ,0x1F39  => array(0x1F31)
-                    ,0x1F3A  => array(0x1F32)
-                    ,0x1F3B  => array(0x1F33)
-                    ,0x1F3C  => array(0x1F34)
-                    ,0x1F3D  => array(0x1F35)
-                    ,0x1F3E  => array(0x1F36)
-                    ,0x1F3F  => array(0x1F37)
-                    ,0x1F48  => array(0x1F40)
-                    ,0x1F49  => array(0x1F41)
-                    ,0x1F4A  => array(0x1F42)
-                    ,0x1F4B  => array(0x1F43)
-                    ,0x1F4C  => array(0x1F44)
-                    ,0x1F4D  => array(0x1F45)
-                    ,0x1F50  => array(0x3C5, 0x313)
-                    ,0x1F52  => array(0x3C5, 0x313, 0x300)
-                    ,0x1F54  => array(0x3C5, 0x313, 0x301)
-                    ,0x1F56  => array(0x3C5, 0x313, 0x342)
-                    ,0x1F59  => array(0x1F51)
-                    ,0x1F5B  => array(0x1F53)
-                    ,0x1F5D  => array(0x1F55)
-                    ,0x1F5F  => array(0x1F57)
-                    ,0x1F68  => array(0x1F60)
-                    ,0x1F69  => array(0x1F61)
-                    ,0x1F6A  => array(0x1F62)
-                    ,0x1F6B  => array(0x1F63)
-                    ,0x1F6C  => array(0x1F64)
-                    ,0x1F6D  => array(0x1F65)
-                    ,0x1F6E  => array(0x1F66)
-                    ,0x1F6F  => array(0x1F67)
-                    ,0x1F80  => array(0x1F00, 0x3B9)
-                    ,0x1F81  => array(0x1F01, 0x3B9)
-                    ,0x1F82  => array(0x1F02, 0x3B9)
-                    ,0x1F83  => array(0x1F03, 0x3B9)
-                    ,0x1F84  => array(0x1F04, 0x3B9)
-                    ,0x1F85  => array(0x1F05, 0x3B9)
-                    ,0x1F86  => array(0x1F06, 0x3B9)
-                    ,0x1F87  => array(0x1F07, 0x3B9)
-                    ,0x1F88  => array(0x1F00, 0x3B9)
-                    ,0x1F89  => array(0x1F01, 0x3B9)
-                    ,0x1F8A  => array(0x1F02, 0x3B9)
-                    ,0x1F8B  => array(0x1F03, 0x3B9)
-                    ,0x1F8C  => array(0x1F04, 0x3B9)
-                    ,0x1F8D  => array(0x1F05, 0x3B9)
-                    ,0x1F8E  => array(0x1F06, 0x3B9)
-                    ,0x1F8F  => array(0x1F07, 0x3B9)
-                    ,0x1F90  => array(0x1F20, 0x3B9)
-                    ,0x1F91  => array(0x1F21, 0x3B9)
-                    ,0x1F92  => array(0x1F22, 0x3B9)
-                    ,0x1F93  => array(0x1F23, 0x3B9)
-                    ,0x1F94  => array(0x1F24, 0x3B9)
-                    ,0x1F95  => array(0x1F25, 0x3B9)
-                    ,0x1F96  => array(0x1F26, 0x3B9)
-                    ,0x1F97  => array(0x1F27, 0x3B9)
-                    ,0x1F98  => array(0x1F20, 0x3B9)
-                    ,0x1F99  => array(0x1F21, 0x3B9)
-                    ,0x1F9A  => array(0x1F22, 0x3B9)
-                    ,0x1F9B  => array(0x1F23, 0x3B9)
-                    ,0x1F9C  => array(0x1F24, 0x3B9)
-                    ,0x1F9D  => array(0x1F25, 0x3B9)
-                    ,0x1F9E  => array(0x1F26, 0x3B9)
-                    ,0x1F9F  => array(0x1F27, 0x3B9)
-                    ,0x1FA0  => array(0x1F60, 0x3B9)
-                    ,0x1FA1  => array(0x1F61, 0x3B9)
-                    ,0x1FA2  => array(0x1F62, 0x3B9)
-                    ,0x1FA3  => array(0x1F63, 0x3B9)
-                    ,0x1FA4  => array(0x1F64, 0x3B9)
-                    ,0x1FA5  => array(0x1F65, 0x3B9)
-                    ,0x1FA6  => array(0x1F66, 0x3B9)
-                    ,0x1FA7  => array(0x1F67, 0x3B9)
-                    ,0x1FA8  => array(0x1F60, 0x3B9)
-                    ,0x1FA9  => array(0x1F61, 0x3B9)
-                    ,0x1FAA  => array(0x1F62, 0x3B9)
-                    ,0x1FAB  => array(0x1F63, 0x3B9)
-                    ,0x1FAC  => array(0x1F64, 0x3B9)
-                    ,0x1FAD  => array(0x1F65, 0x3B9)
-                    ,0x1FAE  => array(0x1F66, 0x3B9)
-                    ,0x1FAF  => array(0x1F67, 0x3B9)
-                    ,0x1FB2  => array(0x1F70, 0x3B9)
-                    ,0x1FB3  => array(0x3B1, 0x3B9)
-                    ,0x1FB4  => array(0x3AC, 0x3B9)
-                    ,0x1FB6  => array(0x3B1, 0x342)
-                    ,0x1FB7  => array(0x3B1, 0x342, 0x3B9)
-                    ,0x1FB8  => array(0x1FB0)
-                    ,0x1FB9  => array(0x1FB1)
-                    ,0x1FBA  => array(0x1F70)
-                    ,0x1FBB  => array(0x1F71)
-                    ,0x1FBC  => array(0x3B1, 0x3B9)
-                    ,0x1FBE  => array(0x3B9)
-                    ,0x1FC2  => array(0x1F74, 0x3B9)
-                    ,0x1FC3  => array(0x3B7, 0x3B9)
-                    ,0x1FC4  => array(0x3AE, 0x3B9)
-                    ,0x1FC6  => array(0x3B7, 0x342)
-                    ,0x1FC7  => array(0x3B7, 0x342, 0x3B9)
-                    ,0x1FC8  => array(0x1F72)
-                    ,0x1FC9  => array(0x1F73)
-                    ,0x1FCA  => array(0x1F74)
-                    ,0x1FCB  => array(0x1F75)
-                    ,0x1FCC  => array(0x3B7, 0x3B9)
-                    ,0x1FD2  => array(0x3B9, 0x308, 0x300)
-                    ,0x1FD3  => array(0x3B9, 0x308, 0x301)
-                    ,0x1FD6  => array(0x3B9, 0x342)
-                    ,0x1FD7  => array(0x3B9, 0x308, 0x342)
-                    ,0x1FD8  => array(0x1FD0)
-                    ,0x1FD9  => array(0x1FD1)
-                    ,0x1FDA  => array(0x1F76)
-                    ,0x1FDB  => array(0x1F77)
-                    ,0x1FE2  => array(0x3C5, 0x308, 0x300)
-                    ,0x1FE3  => array(0x3C5, 0x308, 0x301)
-                    ,0x1FE4  => array(0x3C1, 0x313)
-                    ,0x1FE6  => array(0x3C5, 0x342)
-                    ,0x1FE7  => array(0x3C5, 0x308, 0x342)
-                    ,0x1FE8  => array(0x1FE0)
-                    ,0x1FE9  => array(0x1FE1)
-                    ,0x1FEA  => array(0x1F7A)
-                    ,0x1FEB  => array(0x1F7B)
-                    ,0x1FEC  => array(0x1FE5)
-                    ,0x1FF2  => array(0x1F7C, 0x3B9)
-                    ,0x1FF3  => array(0x3C9, 0x3B9)
-                    ,0x1FF4  => array(0x3CE, 0x3B9)
-                    ,0x1FF6  => array(0x3C9, 0x342)
-                    ,0x1FF7  => array(0x3C9, 0x342, 0x3B9)
-                    ,0x1FF8  => array(0x1F78)
-                    ,0x1FF9  => array(0x1F79)
-                    ,0x1FFA  => array(0x1F7C)
-                    ,0x1FFB  => array(0x1F7D)
-                    ,0x1FFC  => array(0x3C9, 0x3B9)
-                    ,0x20A8  => array(0x72, 0x73)
-                    ,0x2102  => array(0x63)
-                    ,0x2103  => array(0xB0, 0x63)
-                    ,0x2107  => array(0x25B)
-                    ,0x2109  => array(0xB0, 0x66)
-                    ,0x210B  => array(0x68)
-                    ,0x210C  => array(0x68)
-                    ,0x210D  => array(0x68)
-                    ,0x2110  => array(0x69)
-                    ,0x2111  => array(0x69)
-                    ,0x2112  => array(0x6C)
-                    ,0x2115  => array(0x6E)
-                    ,0x2116  => array(0x6E, 0x6F)
-                    ,0x2119  => array(0x70)
-                    ,0x211A  => array(0x71)
-                    ,0x211B  => array(0x72)
-                    ,0x211C  => array(0x72)
-                    ,0x211D  => array(0x72)
-                    ,0x2120  => array(0x73, 0x6D)
-                    ,0x2121  => array(0x74, 0x65, 0x6C)
-                    ,0x2122  => array(0x74, 0x6D)
-                    ,0x2124  => array(0x7A)
-                    ,0x2126  => array(0x3C9)
-                    ,0x2128  => array(0x7A)
-                    ,0x212A  => array(0x6B)
-                    ,0x212B  => array(0xE5)
-                    ,0x212C  => array(0x62)
-                    ,0x212D  => array(0x63)
-                    ,0x2130  => array(0x65)
-                    ,0x2131  => array(0x66)
-                    ,0x2133  => array(0x6D)
-                    ,0x213E  => array(0x3B3)
-                    ,0x213F  => array(0x3C0)
-                    ,0x2145  => array(0x64)
-                    ,0x2160  => array(0x2170)
-                    ,0x2161  => array(0x2171)
-                    ,0x2162  => array(0x2172)
-                    ,0x2163  => array(0x2173)
-                    ,0x2164  => array(0x2174)
-                    ,0x2165  => array(0x2175)
-                    ,0x2166  => array(0x2176)
-                    ,0x2167  => array(0x2177)
-                    ,0x2168  => array(0x2178)
-                    ,0x2169  => array(0x2179)
-                    ,0x216A  => array(0x217A)
-                    ,0x216B  => array(0x217B)
-                    ,0x216C  => array(0x217C)
-                    ,0x216D  => array(0x217D)
-                    ,0x216E  => array(0x217E)
-                    ,0x216F  => array(0x217F)
-                    ,0x24B6  => array(0x24D0)
-                    ,0x24B7  => array(0x24D1)
-                    ,0x24B8  => array(0x24D2)
-                    ,0x24B9  => array(0x24D3)
-                    ,0x24BA  => array(0x24D4)
-                    ,0x24BB  => array(0x24D5)
-                    ,0x24BC  => array(0x24D6)
-                    ,0x24BD  => array(0x24D7)
-                    ,0x24BE  => array(0x24D8)
-                    ,0x24BF  => array(0x24D9)
-                    ,0x24C0  => array(0x24DA)
-                    ,0x24C1  => array(0x24DB)
-                    ,0x24C2  => array(0x24DC)
-                    ,0x24C3  => array(0x24DD)
-                    ,0x24C4  => array(0x24DE)
-                    ,0x24C5  => array(0x24DF)
-                    ,0x24C6  => array(0x24E0)
-                    ,0x24C7  => array(0x24E1)
-                    ,0x24C8  => array(0x24E2)
-                    ,0x24C9  => array(0x24E3)
-                    ,0x24CA  => array(0x24E4)
-                    ,0x24CB  => array(0x24E5)
-                    ,0x24CC  => array(0x24E6)
-                    ,0x24CD  => array(0x24E7)
-                    ,0x24CE  => array(0x24E8)
-                    ,0x24CF  => array(0x24E9)
-                    ,0x3371  => array(0x68, 0x70, 0x61)
-                    ,0x3373  => array(0x61, 0x75)
-                    ,0x3375  => array(0x6F, 0x76)
-                    ,0x3380  => array(0x70, 0x61)
-                    ,0x3381  => array(0x6E, 0x61)
-                    ,0x3382  => array(0x3BC, 0x61)
-                    ,0x3383  => array(0x6D, 0x61)
-                    ,0x3384  => array(0x6B, 0x61)
-                    ,0x3385  => array(0x6B, 0x62)
-                    ,0x3386  => array(0x6D, 0x62)
-                    ,0x3387  => array(0x67, 0x62)
-                    ,0x338A  => array(0x70, 0x66)
-                    ,0x338B  => array(0x6E, 0x66)
-                    ,0x338C  => array(0x3BC, 0x66)
-                    ,0x3390  => array(0x68, 0x7A)
-                    ,0x3391  => array(0x6B, 0x68, 0x7A)
-                    ,0x3392  => array(0x6D, 0x68, 0x7A)
-                    ,0x3393  => array(0x67, 0x68, 0x7A)
-                    ,0x3394  => array(0x74, 0x68, 0x7A)
-                    ,0x33A9  => array(0x70, 0x61)
-                    ,0x33AA  => array(0x6B, 0x70, 0x61)
-                    ,0x33AB  => array(0x6D, 0x70, 0x61)
-                    ,0x33AC  => array(0x67, 0x70, 0x61)
-                    ,0x33B4  => array(0x70, 0x76)
-                    ,0x33B5  => array(0x6E, 0x76)
-                    ,0x33B6  => array(0x3BC, 0x76)
-                    ,0x33B7  => array(0x6D, 0x76)
-                    ,0x33B8  => array(0x6B, 0x76)
-                    ,0x33B9  => array(0x6D, 0x76)
-                    ,0x33BA  => array(0x70, 0x77)
-                    ,0x33BB  => array(0x6E, 0x77)
-                    ,0x33BC  => array(0x3BC, 0x77)
-                    ,0x33BD  => array(0x6D, 0x77)
-                    ,0x33BE  => array(0x6B, 0x77)
-                    ,0x33BF  => array(0x6D, 0x77)
-                    ,0x33C0  => array(0x6B, 0x3C9)
-                    ,0x33C1  => array(0x6D, 0x3C9) /*
-                    ,0x33C2  => array(0x61, 0x2E, 0x6D, 0x2E) */
-                    ,0x33C3  => array(0x62, 0x71)
-                    ,0x33C6  => array(0x63, 0x2215, 0x6B, 0x67)
-                    ,0x33C7  => array(0x63, 0x6F, 0x2E)
-                    ,0x33C8  => array(0x64, 0x62)
-                    ,0x33C9  => array(0x67, 0x79)
-                    ,0x33CB  => array(0x68, 0x70)
-                    ,0x33CD  => array(0x6B, 0x6B)
-                    ,0x33CE  => array(0x6B, 0x6D)
-                    ,0x33D7  => array(0x70, 0x68)
-                    ,0x33D9  => array(0x70, 0x70, 0x6D)
-                    ,0x33DA  => array(0x70, 0x72)
-                    ,0x33DC  => array(0x73, 0x76)
-                    ,0x33DD  => array(0x77, 0x62)
-                    ,0xFB00  => array(0x66, 0x66)
-                    ,0xFB01  => array(0x66, 0x69)
-                    ,0xFB02  => array(0x66, 0x6C)
-                    ,0xFB03  => array(0x66, 0x66, 0x69)
-                    ,0xFB04  => array(0x66, 0x66, 0x6C)
-                    ,0xFB05  => array(0x73, 0x74)
-                    ,0xFB06  => array(0x73, 0x74)
-                    ,0xFB13  => array(0x574, 0x576)
-                    ,0xFB14  => array(0x574, 0x565)
-                    ,0xFB15  => array(0x574, 0x56B)
-                    ,0xFB16  => array(0x57E, 0x576)
-                    ,0xFB17  => array(0x574, 0x56D)
-                    ,0xFF21  => array(0xFF41)
-                    ,0xFF22  => array(0xFF42)
-                    ,0xFF23  => array(0xFF43)
-                    ,0xFF24  => array(0xFF44)
-                    ,0xFF25  => array(0xFF45)
-                    ,0xFF26  => array(0xFF46)
-                    ,0xFF27  => array(0xFF47)
-                    ,0xFF28  => array(0xFF48)
-                    ,0xFF29  => array(0xFF49)
-                    ,0xFF2A  => array(0xFF4A)
-                    ,0xFF2B  => array(0xFF4B)
-                    ,0xFF2C  => array(0xFF4C)
-                    ,0xFF2D  => array(0xFF4D)
-                    ,0xFF2E  => array(0xFF4E)
-                    ,0xFF2F  => array(0xFF4F)
-                    ,0xFF30  => array(0xFF50)
-                    ,0xFF31  => array(0xFF51)
-                    ,0xFF32  => array(0xFF52)
-                    ,0xFF33  => array(0xFF53)
-                    ,0xFF34  => array(0xFF54)
-                    ,0xFF35  => array(0xFF55)
-                    ,0xFF36  => array(0xFF56)
-                    ,0xFF37  => array(0xFF57)
-                    ,0xFF38  => array(0xFF58)
-                    ,0xFF39  => array(0xFF59)
-                    ,0xFF3A  => array(0xFF5A)
-                    ,0x10400 => array(0x10428)
-                    ,0x10401 => array(0x10429)
-                    ,0x10402 => array(0x1042A)
-                    ,0x10403 => array(0x1042B)
-                    ,0x10404 => array(0x1042C)
-                    ,0x10405 => array(0x1042D)
-                    ,0x10406 => array(0x1042E)
-                    ,0x10407 => array(0x1042F)
-                    ,0x10408 => array(0x10430)
-                    ,0x10409 => array(0x10431)
-                    ,0x1040A => array(0x10432)
-                    ,0x1040B => array(0x10433)
-                    ,0x1040C => array(0x10434)
-                    ,0x1040D => array(0x10435)
-                    ,0x1040E => array(0x10436)
-                    ,0x1040F => array(0x10437)
-                    ,0x10410 => array(0x10438)
-                    ,0x10411 => array(0x10439)
-                    ,0x10412 => array(0x1043A)
-                    ,0x10413 => array(0x1043B)
-                    ,0x10414 => array(0x1043C)
-                    ,0x10415 => array(0x1043D)
-                    ,0x10416 => array(0x1043E)
-                    ,0x10417 => array(0x1043F)
-                    ,0x10418 => array(0x10440)
-                    ,0x10419 => array(0x10441)
-                    ,0x1041A => array(0x10442)
-                    ,0x1041B => array(0x10443)
-                    ,0x1041C => array(0x10444)
-                    ,0x1041D => array(0x10445)
-                    ,0x1041E => array(0x10446)
-                    ,0x1041F => array(0x10447)
-                    ,0x10420 => array(0x10448)
-                    ,0x10421 => array(0x10449)
-                    ,0x10422 => array(0x1044A)
-                    ,0x10423 => array(0x1044B)
-                    ,0x10424 => array(0x1044C)
-                    ,0x10425 => array(0x1044D)
-                    ,0x1D400 => array(0x61)
-                    ,0x1D401 => array(0x62)
-                    ,0x1D402 => array(0x63)
-                    ,0x1D403 => array(0x64)
-                    ,0x1D404 => array(0x65)
-                    ,0x1D405 => array(0x66)
-                    ,0x1D406 => array(0x67)
-                    ,0x1D407 => array(0x68)
-                    ,0x1D408 => array(0x69)
-                    ,0x1D409 => array(0x6A)
-                    ,0x1D40A => array(0x6B)
-                    ,0x1D40B => array(0x6C)
-                    ,0x1D40C => array(0x6D)
-                    ,0x1D40D => array(0x6E)
-                    ,0x1D40E => array(0x6F)
-                    ,0x1D40F => array(0x70)
-                    ,0x1D410 => array(0x71)
-                    ,0x1D411 => array(0x72)
-                    ,0x1D412 => array(0x73)
-                    ,0x1D413 => array(0x74)
-                    ,0x1D414 => array(0x75)
-                    ,0x1D415 => array(0x76)
-                    ,0x1D416 => array(0x77)
-                    ,0x1D417 => array(0x78)
-                    ,0x1D418 => array(0x79)
-                    ,0x1D419 => array(0x7A)
-                    ,0x1D434 => array(0x61)
-                    ,0x1D435 => array(0x62)
-                    ,0x1D436 => array(0x63)
-                    ,0x1D437 => array(0x64)
-                    ,0x1D438 => array(0x65)
-                    ,0x1D439 => array(0x66)
-                    ,0x1D43A => array(0x67)
-                    ,0x1D43B => array(0x68)
-                    ,0x1D43C => array(0x69)
-                    ,0x1D43D => array(0x6A)
-                    ,0x1D43E => array(0x6B)
-                    ,0x1D43F => array(0x6C)
-                    ,0x1D440 => array(0x6D)
-                    ,0x1D441 => array(0x6E)
-                    ,0x1D442 => array(0x6F)
-                    ,0x1D443 => array(0x70)
-                    ,0x1D444 => array(0x71)
-                    ,0x1D445 => array(0x72)
-                    ,0x1D446 => array(0x73)
-                    ,0x1D447 => array(0x74)
-                    ,0x1D448 => array(0x75)
-                    ,0x1D449 => array(0x76)
-                    ,0x1D44A => array(0x77)
-                    ,0x1D44B => array(0x78)
-                    ,0x1D44C => array(0x79)
-                    ,0x1D44D => array(0x7A)
-                    ,0x1D468 => array(0x61)
-                    ,0x1D469 => array(0x62)
-                    ,0x1D46A => array(0x63)
-                    ,0x1D46B => array(0x64)
-                    ,0x1D46C => array(0x65)
-                    ,0x1D46D => array(0x66)
-                    ,0x1D46E => array(0x67)
-                    ,0x1D46F => array(0x68)
-                    ,0x1D470 => array(0x69)
-                    ,0x1D471 => array(0x6A)
-                    ,0x1D472 => array(0x6B)
-                    ,0x1D473 => array(0x6C)
-                    ,0x1D474 => array(0x6D)
-                    ,0x1D475 => array(0x6E)
-                    ,0x1D476 => array(0x6F)
-                    ,0x1D477 => array(0x70)
-                    ,0x1D478 => array(0x71)
-                    ,0x1D479 => array(0x72)
-                    ,0x1D47A => array(0x73)
-                    ,0x1D47B => array(0x74)
-                    ,0x1D47C => array(0x75)
-                    ,0x1D47D => array(0x76)
-                    ,0x1D47E => array(0x77)
-                    ,0x1D47F => array(0x78)
-                    ,0x1D480 => array(0x79)
-                    ,0x1D481 => array(0x7A)
-                    ,0x1D49C => array(0x61)
-                    ,0x1D49E => array(0x63)
-                    ,0x1D49F => array(0x64)
-                    ,0x1D4A2 => array(0x67)
-                    ,0x1D4A5 => array(0x6A)
-                    ,0x1D4A6 => array(0x6B)
-                    ,0x1D4A9 => array(0x6E)
-                    ,0x1D4AA => array(0x6F)
-                    ,0x1D4AB => array(0x70)
-                    ,0x1D4AC => array(0x71)
-                    ,0x1D4AE => array(0x73)
-                    ,0x1D4AF => array(0x74)
-                    ,0x1D4B0 => array(0x75)
-                    ,0x1D4B1 => array(0x76)
-                    ,0x1D4B2 => array(0x77)
-                    ,0x1D4B3 => array(0x78)
-                    ,0x1D4B4 => array(0x79)
-                    ,0x1D4B5 => array(0x7A)
-                    ,0x1D4D0 => array(0x61)
-                    ,0x1D4D1 => array(0x62)
-                    ,0x1D4D2 => array(0x63)
-                    ,0x1D4D3 => array(0x64)
-                    ,0x1D4D4 => array(0x65)
-                    ,0x1D4D5 => array(0x66)
-                    ,0x1D4D6 => array(0x67)
-                    ,0x1D4D7 => array(0x68)
-                    ,0x1D4D8 => array(0x69)
-                    ,0x1D4D9 => array(0x6A)
-                    ,0x1D4DA => array(0x6B)
-                    ,0x1D4DB => array(0x6C)
-                    ,0x1D4DC => array(0x6D)
-                    ,0x1D4DD => array(0x6E)
-                    ,0x1D4DE => array(0x6F)
-                    ,0x1D4DF => array(0x70)
-                    ,0x1D4E0 => array(0x71)
-                    ,0x1D4E1 => array(0x72)
-                    ,0x1D4E2 => array(0x73)
-                    ,0x1D4E3 => array(0x74)
-                    ,0x1D4E4 => array(0x75)
-                    ,0x1D4E5 => array(0x76)
-                    ,0x1D4E6 => array(0x77)
-                    ,0x1D4E7 => array(0x78)
-                    ,0x1D4E8 => array(0x79)
-                    ,0x1D4E9 => array(0x7A)
-                    ,0x1D504 => array(0x61)
-                    ,0x1D505 => array(0x62)
-                    ,0x1D507 => array(0x64)
-                    ,0x1D508 => array(0x65)
-                    ,0x1D509 => array(0x66)
-                    ,0x1D50A => array(0x67)
-                    ,0x1D50D => array(0x6A)
-                    ,0x1D50E => array(0x6B)
-                    ,0x1D50F => array(0x6C)
-                    ,0x1D510 => array(0x6D)
-                    ,0x1D511 => array(0x6E)
-                    ,0x1D512 => array(0x6F)
-                    ,0x1D513 => array(0x70)
-                    ,0x1D514 => array(0x71)
-                    ,0x1D516 => array(0x73)
-                    ,0x1D517 => array(0x74)
-                    ,0x1D518 => array(0x75)
-                    ,0x1D519 => array(0x76)
-                    ,0x1D51A => array(0x77)
-                    ,0x1D51B => array(0x78)
-                    ,0x1D51C => array(0x79)
-                    ,0x1D538 => array(0x61)
-                    ,0x1D539 => array(0x62)
-                    ,0x1D53B => array(0x64)
-                    ,0x1D53C => array(0x65)
-                    ,0x1D53D => array(0x66)
-                    ,0x1D53E => array(0x67)
-                    ,0x1D540 => array(0x69)
-                    ,0x1D541 => array(0x6A)
-                    ,0x1D542 => array(0x6B)
-                    ,0x1D543 => array(0x6C)
-                    ,0x1D544 => array(0x6D)
-                    ,0x1D546 => array(0x6F)
-                    ,0x1D54A => array(0x73)
-                    ,0x1D54B => array(0x74)
-                    ,0x1D54C => array(0x75)
-                    ,0x1D54D => array(0x76)
-                    ,0x1D54E => array(0x77)
-                    ,0x1D54F => array(0x78)
-                    ,0x1D550 => array(0x79)
-                    ,0x1D56C => array(0x61)
-                    ,0x1D56D => array(0x62)
-                    ,0x1D56E => array(0x63)
-                    ,0x1D56F => array(0x64)
-                    ,0x1D570 => array(0x65)
-                    ,0x1D571 => array(0x66)
-                    ,0x1D572 => array(0x67)
-                    ,0x1D573 => array(0x68)
-                    ,0x1D574 => array(0x69)
-                    ,0x1D575 => array(0x6A)
-                    ,0x1D576 => array(0x6B)
-                    ,0x1D577 => array(0x6C)
-                    ,0x1D578 => array(0x6D)
-                    ,0x1D579 => array(0x6E)
-                    ,0x1D57A => array(0x6F)
-                    ,0x1D57B => array(0x70)
-                    ,0x1D57C => array(0x71)
-                    ,0x1D57D => array(0x72)
-                    ,0x1D57E => array(0x73)
-                    ,0x1D57F => array(0x74)
-                    ,0x1D580 => array(0x75)
-                    ,0x1D581 => array(0x76)
-                    ,0x1D582 => array(0x77)
-                    ,0x1D583 => array(0x78)
-                    ,0x1D584 => array(0x79)
-                    ,0x1D585 => array(0x7A)
-                    ,0x1D5A0 => array(0x61)
-                    ,0x1D5A1 => array(0x62)
-                    ,0x1D5A2 => array(0x63)
-                    ,0x1D5A3 => array(0x64)
-                    ,0x1D5A4 => array(0x65)
-                    ,0x1D5A5 => array(0x66)
-                    ,0x1D5A6 => array(0x67)
-                    ,0x1D5A7 => array(0x68)
-                    ,0x1D5A8 => array(0x69)
-                    ,0x1D5A9 => array(0x6A)
-                    ,0x1D5AA => array(0x6B)
-                    ,0x1D5AB => array(0x6C)
-                    ,0x1D5AC => array(0x6D)
-                    ,0x1D5AD => array(0x6E)
-                    ,0x1D5AE => array(0x6F)
-                    ,0x1D5AF => array(0x70)
-                    ,0x1D5B0 => array(0x71)
-                    ,0x1D5B1 => array(0x72)
-                    ,0x1D5B2 => array(0x73)
-                    ,0x1D5B3 => array(0x74)
-                    ,0x1D5B4 => array(0x75)
-                    ,0x1D5B5 => array(0x76)
-                    ,0x1D5B6 => array(0x77)
-                    ,0x1D5B7 => array(0x78)
-                    ,0x1D5B8 => array(0x79)
-                    ,0x1D5B9 => array(0x7A)
-                    ,0x1D5D4 => array(0x61)
-                    ,0x1D5D5 => array(0x62)
-                    ,0x1D5D6 => array(0x63)
-                    ,0x1D5D7 => array(0x64)
-                    ,0x1D5D8 => array(0x65)
-                    ,0x1D5D9 => array(0x66)
-                    ,0x1D5DA => array(0x67)
-                    ,0x1D5DB => array(0x68)
-                    ,0x1D5DC => array(0x69)
-                    ,0x1D5DD => array(0x6A)
-                    ,0x1D5DE => array(0x6B)
-                    ,0x1D5DF => array(0x6C)
-                    ,0x1D5E0 => array(0x6D)
-                    ,0x1D5E1 => array(0x6E)
-                    ,0x1D5E2 => array(0x6F)
-                    ,0x1D5E3 => array(0x70)
-                    ,0x1D5E4 => array(0x71)
-                    ,0x1D5E5 => array(0x72)
-                    ,0x1D5E6 => array(0x73)
-                    ,0x1D5E7 => array(0x74)
-                    ,0x1D5E8 => array(0x75)
-                    ,0x1D5E9 => array(0x76)
-                    ,0x1D5EA => array(0x77)
-                    ,0x1D5EB => array(0x78)
-                    ,0x1D5EC => array(0x79)
-                    ,0x1D5ED => array(0x7A)
-                    ,0x1D608 => array(0x61)
-                    ,0x1D609 => array(0x62)
-                    ,0x1D60A => array(0x63)
-                    ,0x1D60B => array(0x64)
-                    ,0x1D60C => array(0x65)
-                    ,0x1D60D => array(0x66)
-                    ,0x1D60E => array(0x67)
-                    ,0x1D60F => array(0x68)
-                    ,0x1D610 => array(0x69)
-                    ,0x1D611 => array(0x6A)
-                    ,0x1D612 => array(0x6B)
-                    ,0x1D613 => array(0x6C)
-                    ,0x1D614 => array(0x6D)
-                    ,0x1D615 => array(0x6E)
-                    ,0x1D616 => array(0x6F)
-                    ,0x1D617 => array(0x70)
-                    ,0x1D618 => array(0x71)
-                    ,0x1D619 => array(0x72)
-                    ,0x1D61A => array(0x73)
-                    ,0x1D61B => array(0x74)
-                    ,0x1D61C => array(0x75)
-                    ,0x1D61D => array(0x76)
-                    ,0x1D61E => array(0x77)
-                    ,0x1D61F => array(0x78)
-                    ,0x1D620 => array(0x79)
-                    ,0x1D621 => array(0x7A)
-                    ,0x1D63C => array(0x61)
-                    ,0x1D63D => array(0x62)
-                    ,0x1D63E => array(0x63)
-                    ,0x1D63F => array(0x64)
-                    ,0x1D640 => array(0x65)
-                    ,0x1D641 => array(0x66)
-                    ,0x1D642 => array(0x67)
-                    ,0x1D643 => array(0x68)
-                    ,0x1D644 => array(0x69)
-                    ,0x1D645 => array(0x6A)
-                    ,0x1D646 => array(0x6B)
-                    ,0x1D647 => array(0x6C)
-                    ,0x1D648 => array(0x6D)
-                    ,0x1D649 => array(0x6E)
-                    ,0x1D64A => array(0x6F)
-                    ,0x1D64B => array(0x70)
-                    ,0x1D64C => array(0x71)
-                    ,0x1D64D => array(0x72)
-                    ,0x1D64E => array(0x73)
-                    ,0x1D64F => array(0x74)
-                    ,0x1D650 => array(0x75)
-                    ,0x1D651 => array(0x76)
-                    ,0x1D652 => array(0x77)
-                    ,0x1D653 => array(0x78)
-                    ,0x1D654 => array(0x79)
-                    ,0x1D655 => array(0x7A)
-                    ,0x1D670 => array(0x61)
-                    ,0x1D671 => array(0x62)
-                    ,0x1D672 => array(0x63)
-                    ,0x1D673 => array(0x64)
-                    ,0x1D674 => array(0x65)
-                    ,0x1D675 => array(0x66)
-                    ,0x1D676 => array(0x67)
-                    ,0x1D677 => array(0x68)
-                    ,0x1D678 => array(0x69)
-                    ,0x1D679 => array(0x6A)
-                    ,0x1D67A => array(0x6B)
-                    ,0x1D67B => array(0x6C)
-                    ,0x1D67C => array(0x6D)
-                    ,0x1D67D => array(0x6E)
-                    ,0x1D67E => array(0x6F)
-                    ,0x1D67F => array(0x70)
-                    ,0x1D680 => array(0x71)
-                    ,0x1D681 => array(0x72)
-                    ,0x1D682 => array(0x73)
-                    ,0x1D683 => array(0x74)
-                    ,0x1D684 => array(0x75)
-                    ,0x1D685 => array(0x76)
-                    ,0x1D686 => array(0x77)
-                    ,0x1D687 => array(0x78)
-                    ,0x1D688 => array(0x79)
-                    ,0x1D689 => array(0x7A)
-                    ,0x1D6A8 => array(0x3B1)
-                    ,0x1D6A9 => array(0x3B2)
-                    ,0x1D6AA => array(0x3B3)
-                    ,0x1D6AB => array(0x3B4)
-                    ,0x1D6AC => array(0x3B5)
-                    ,0x1D6AD => array(0x3B6)
-                    ,0x1D6AE => array(0x3B7)
-                    ,0x1D6AF => array(0x3B8)
-                    ,0x1D6B0 => array(0x3B9)
-                    ,0x1D6B1 => array(0x3BA)
-                    ,0x1D6B2 => array(0x3BB)
-                    ,0x1D6B3 => array(0x3BC)
-                    ,0x1D6B4 => array(0x3BD)
-                    ,0x1D6B5 => array(0x3BE)
-                    ,0x1D6B6 => array(0x3BF)
-                    ,0x1D6B7 => array(0x3C0)
-                    ,0x1D6B8 => array(0x3C1)
-                    ,0x1D6B9 => array(0x3B8)
-                    ,0x1D6BA => array(0x3C3)
-                    ,0x1D6BB => array(0x3C4)
-                    ,0x1D6BC => array(0x3C5)
-                    ,0x1D6BD => array(0x3C6)
-                    ,0x1D6BE => array(0x3C7)
-                    ,0x1D6BF => array(0x3C8)
-                    ,0x1D6C0 => array(0x3C9)
-                    ,0x1D6D3 => array(0x3C3)
-                    ,0x1D6E2 => array(0x3B1)
-                    ,0x1D6E3 => array(0x3B2)
-                    ,0x1D6E4 => array(0x3B3)
-                    ,0x1D6E5 => array(0x3B4)
-                    ,0x1D6E6 => array(0x3B5)
-                    ,0x1D6E7 => array(0x3B6)
-                    ,0x1D6E8 => array(0x3B7)
-                    ,0x1D6E9 => array(0x3B8)
-                    ,0x1D6EA => array(0x3B9)
-                    ,0x1D6EB => array(0x3BA)
-                    ,0x1D6EC => array(0x3BB)
-                    ,0x1D6ED => array(0x3BC)
-                    ,0x1D6EE => array(0x3BD)
-                    ,0x1D6EF => array(0x3BE)
-                    ,0x1D6F0 => array(0x3BF)
-                    ,0x1D6F1 => array(0x3C0)
-                    ,0x1D6F2 => array(0x3C1)
-                    ,0x1D6F3 => array(0x3B8)
-                    ,0x1D6F4 => array(0x3C3)
-                    ,0x1D6F5 => array(0x3C4)
-                    ,0x1D6F6 => array(0x3C5)
-                    ,0x1D6F7 => array(0x3C6)
-                    ,0x1D6F8 => array(0x3C7)
-                    ,0x1D6F9 => array(0x3C8)
-                    ,0x1D6FA => array(0x3C9)
-                    ,0x1D70D => array(0x3C3)
-                    ,0x1D71C => array(0x3B1)
-                    ,0x1D71D => array(0x3B2)
-                    ,0x1D71E => array(0x3B3)
-                    ,0x1D71F => array(0x3B4)
-                    ,0x1D720 => array(0x3B5)
-                    ,0x1D721 => array(0x3B6)
-                    ,0x1D722 => array(0x3B7)
-                    ,0x1D723 => array(0x3B8)
-                    ,0x1D724 => array(0x3B9)
-                    ,0x1D725 => array(0x3BA)
-                    ,0x1D726 => array(0x3BB)
-                    ,0x1D727 => array(0x3BC)
-                    ,0x1D728 => array(0x3BD)
-                    ,0x1D729 => array(0x3BE)
-                    ,0x1D72A => array(0x3BF)
-                    ,0x1D72B => array(0x3C0)
-                    ,0x1D72C => array(0x3C1)
-                    ,0x1D72D => array(0x3B8)
-                    ,0x1D72E => array(0x3C3)
-                    ,0x1D72F => array(0x3C4)
-                    ,0x1D730 => array(0x3C5)
-                    ,0x1D731 => array(0x3C6)
-                    ,0x1D732 => array(0x3C7)
-                    ,0x1D733 => array(0x3C8)
-                    ,0x1D734 => array(0x3C9)
-                    ,0x1D747 => array(0x3C3)
-                    ,0x1D756 => array(0x3B1)
-                    ,0x1D757 => array(0x3B2)
-                    ,0x1D758 => array(0x3B3)
-                    ,0x1D759 => array(0x3B4)
-                    ,0x1D75A => array(0x3B5)
-                    ,0x1D75B => array(0x3B6)
-                    ,0x1D75C => array(0x3B7)
-                    ,0x1D75D => array(0x3B8)
-                    ,0x1D75E => array(0x3B9)
-                    ,0x1D75F => array(0x3BA)
-                    ,0x1D760 => array(0x3BB)
-                    ,0x1D761 => array(0x3BC)
-                    ,0x1D762 => array(0x3BD)
-                    ,0x1D763 => array(0x3BE)
-                    ,0x1D764 => array(0x3BF)
-                    ,0x1D765 => array(0x3C0)
-                    ,0x1D766 => array(0x3C1)
-                    ,0x1D767 => array(0x3B8)
-                    ,0x1D768 => array(0x3C3)
-                    ,0x1D769 => array(0x3C4)
-                    ,0x1D76A => array(0x3C5)
-                    ,0x1D76B => array(0x3C6)
-                    ,0x1D76C => array(0x3C7)
-                    ,0x1D76D => array(0x3C8)
-                    ,0x1D76E => array(0x3C9)
-                    ,0x1D781 => array(0x3C3)
-                    ,0x1D790 => array(0x3B1)
-                    ,0x1D791 => array(0x3B2)
-                    ,0x1D792 => array(0x3B3)
-                    ,0x1D793 => array(0x3B4)
-                    ,0x1D794 => array(0x3B5)
-                    ,0x1D795 => array(0x3B6)
-                    ,0x1D796 => array(0x3B7)
-                    ,0x1D797 => array(0x3B8)
-                    ,0x1D798 => array(0x3B9)
-                    ,0x1D799 => array(0x3BA)
-                    ,0x1D79A => array(0x3BB)
-                    ,0x1D79B => array(0x3BC)
-                    ,0x1D79C => array(0x3BD)
-                    ,0x1D79D => array(0x3BE)
-                    ,0x1D79E => array(0x3BF)
-                    ,0x1D79F => array(0x3C0)
-                    ,0x1D7A0 => array(0x3C1)
-                    ,0x1D7A1 => array(0x3B8)
-                    ,0x1D7A2 => array(0x3C3)
-                    ,0x1D7A3 => array(0x3C4)
-                    ,0x1D7A4 => array(0x3C5)
-                    ,0x1D7A5 => array(0x3C6)
-                    ,0x1D7A6 => array(0x3C7)
-                    ,0x1D7A7 => array(0x3C8)
-                    ,0x1D7A8 => array(0x3C9)
-                    ,0x1D7BB => array(0x3C3)
-                    ,0x3F9   => array(0x3C3)
-                    ,0x1D2C  => array(0x61)
-                    ,0x1D2D  => array(0xE6)
-                    ,0x1D2E  => array(0x62)
-                    ,0x1D30  => array(0x64)
-                    ,0x1D31  => array(0x65)
-                    ,0x1D32  => array(0x1DD)
-                    ,0x1D33  => array(0x67)
-                    ,0x1D34  => array(0x68)
-                    ,0x1D35  => array(0x69)
-                    ,0x1D36  => array(0x6A)
-                    ,0x1D37  => array(0x6B)
-                    ,0x1D38  => array(0x6C)
-                    ,0x1D39  => array(0x6D)
-                    ,0x1D3A  => array(0x6E)
-                    ,0x1D3C  => array(0x6F)
-                    ,0x1D3D  => array(0x223)
-                    ,0x1D3E  => array(0x70)
-                    ,0x1D3F  => array(0x72)
-                    ,0x1D40  => array(0x74)
-                    ,0x1D41  => array(0x75)
-                    ,0x1D42  => array(0x77)
-                    ,0x213B  => array(0x66, 0x61, 0x78)
-                    ,0x3250  => array(0x70, 0x74, 0x65)
-                    ,0x32CC  => array(0x68, 0x67)
-                    ,0x32CE  => array(0x65, 0x76)
-                    ,0x32CF  => array(0x6C, 0x74, 0x64)
-                    ,0x337A  => array(0x69, 0x75)
-                    ,0x33DE  => array(0x76, 0x2215, 0x6D)
-                    ,0x33DF  => array(0x61, 0x2215, 0x6D)
-                    )
-            ,'norm_combcls' => array
-                    (0x334   => 1
-                    ,0x335   => 1
-                    ,0x336   => 1
-                    ,0x337   => 1
-                    ,0x338   => 1
-                    ,0x93C   => 7
-                    ,0x9BC   => 7
-                    ,0xA3C   => 7
-                    ,0xABC   => 7
-                    ,0xB3C   => 7
-                    ,0xCBC   => 7
-                    ,0x1037  => 7
-                    ,0x3099  => 8
-                    ,0x309A  => 8
-                    ,0x94D   => 9
-                    ,0x9CD   => 9
-                    ,0xA4D   => 9
-                    ,0xACD   => 9
-                    ,0xB4D   => 9
-                    ,0xBCD   => 9
-                    ,0xC4D   => 9
-                    ,0xCCD   => 9
-                    ,0xD4D   => 9
-                    ,0xDCA   => 9
-                    ,0xE3A   => 9
-                    ,0xF84   => 9
-                    ,0x1039  => 9
-                    ,0x1714  => 9
-                    ,0x1734  => 9
-                    ,0x17D2  => 9
-                    ,0x5B0   => 10
-                    ,0x5B1   => 11
-                    ,0x5B2   => 12
-                    ,0x5B3   => 13
-                    ,0x5B4   => 14
-                    ,0x5B5   => 15
-                    ,0x5B6   => 16
-                    ,0x5B7   => 17
-                    ,0x5B8   => 18
-                    ,0x5B9   => 19
-                    ,0x5BB   => 20
-                    ,0x5Bc   => 21
-                    ,0x5BD   => 22
-                    ,0x5BF   => 23
-                    ,0x5C1   => 24
-                    ,0x5C2   => 25
-                    ,0xFB1E  => 26
-                    ,0x64B   => 27
-                    ,0x64C   => 28
-                    ,0x64D   => 29
-                    ,0x64E   => 30
-                    ,0x64F   => 31
-                    ,0x650   => 32
-                    ,0x651   => 33
-                    ,0x652   => 34
-                    ,0x670   => 35
-                    ,0x711   => 36
-                    ,0xC55   => 84
-                    ,0xC56   => 91
-                    ,0xE38   => 103
-                    ,0xE39   => 103
-                    ,0xE48   => 107
-                    ,0xE49   => 107
-                    ,0xE4A   => 107
-                    ,0xE4B   => 107
-                    ,0xEB8   => 118
-                    ,0xEB9   => 118
-                    ,0xEC8   => 122
-                    ,0xEC9   => 122
-                    ,0xECA   => 122
-                    ,0xECB   => 122
-                    ,0xF71   => 129
-                    ,0xF72   => 130
-                    ,0xF7A   => 130
-                    ,0xF7B   => 130
-                    ,0xF7C   => 130
-                    ,0xF7D   => 130
-                    ,0xF80   => 130
-                    ,0xF74   => 132
-                    ,0x321   => 202
-                    ,0x322   => 202
-                    ,0x327   => 202
-                    ,0x328   => 202
-                    ,0x31B   => 216
-                    ,0xF39   => 216
-                    ,0x1D165 => 216
-                    ,0x1D166 => 216
-                    ,0x1D16E => 216
-                    ,0x1D16F => 216
-                    ,0x1D170 => 216
-                    ,0x1D171 => 216
-                    ,0x1D172 => 216
-                    ,0x302A  => 218
-                    ,0x316   => 220
-                    ,0x317   => 220
-                    ,0x318   => 220
-                    ,0x319   => 220
-                    ,0x31C   => 220
-                    ,0x31D   => 220
-                    ,0x31E   => 220
-                    ,0x31F   => 220
-                    ,0x320   => 220
-                    ,0x323   => 220
-                    ,0x324   => 220
-                    ,0x325   => 220
-                    ,0x326   => 220
-                    ,0x329   => 220
-                    ,0x32A   => 220
-                    ,0x32B   => 220
-                    ,0x32C   => 220
-                    ,0x32D   => 220
-                    ,0x32E   => 220
-                    ,0x32F   => 220
-                    ,0x330   => 220
-                    ,0x331   => 220
-                    ,0x332   => 220
-                    ,0x333   => 220
-                    ,0x339   => 220
-                    ,0x33A   => 220
-                    ,0x33B   => 220
-                    ,0x33C   => 220
-                    ,0x347   => 220
-                    ,0x348   => 220
-                    ,0x349   => 220
-                    ,0x34D   => 220
-                    ,0x34E   => 220
-                    ,0x353   => 220
-                    ,0x354   => 220
-                    ,0x355   => 220
-                    ,0x356   => 220
-                    ,0x591   => 220
-                    ,0x596   => 220
-                    ,0x59B   => 220
-                    ,0x5A3   => 220
-                    ,0x5A4   => 220
-                    ,0x5A5   => 220
-                    ,0x5A6   => 220
-                    ,0x5A7   => 220
-                    ,0x5AA   => 220
-                    ,0x655   => 220
-                    ,0x656   => 220
-                    ,0x6E3   => 220
-                    ,0x6EA   => 220
-                    ,0x6ED   => 220
-                    ,0x731   => 220
-                    ,0x734   => 220
-                    ,0x737   => 220
-                    ,0x738   => 220
-                    ,0x739   => 220
-                    ,0x73B   => 220
-                    ,0x73C   => 220
-                    ,0x73E   => 220
-                    ,0x742   => 220
-                    ,0x744   => 220
-                    ,0x746   => 220
-                    ,0x748   => 220
-                    ,0x952   => 220
-                    ,0xF18   => 220
-                    ,0xF19   => 220
-                    ,0xF35   => 220
-                    ,0xF37   => 220
-                    ,0xFC6   => 220
-                    ,0x193B  => 220
-                    ,0x20E8  => 220
-                    ,0x1D17B => 220
-                    ,0x1D17C => 220
-                    ,0x1D17D => 220
-                    ,0x1D17E => 220
-                    ,0x1D17F => 220
-                    ,0x1D180 => 220
-                    ,0x1D181 => 220
-                    ,0x1D182 => 220
-                    ,0x1D18A => 220
-                    ,0x1D18B => 220
-                    ,0x59A   => 222
-                    ,0x5AD   => 222
-                    ,0x1929  => 222
-                    ,0x302D  => 222
-                    ,0x302E  => 224
-                    ,0x302F  => 224
-                    ,0x1D16D => 226
-                    ,0x5AE   => 228
-                    ,0x18A9  => 228
-                    ,0x302B  => 228
-                    ,0x300   => 230
-                    ,0x301   => 230
-                    ,0x302   => 230
-                    ,0x303   => 230
-                    ,0x304   => 230
-                    ,0x305   => 230
-                    ,0x306   => 230
-                    ,0x307   => 230
-                    ,0x308   => 230
-                    ,0x309   => 230
-                    ,0x30A   => 230
-                    ,0x30B   => 230
-                    ,0x30C   => 230
-                    ,0x30D   => 230
-                    ,0x30E   => 230
-                    ,0x30F   => 230
-                    ,0x310   => 230
-                    ,0x311   => 230
-                    ,0x312   => 230
-                    ,0x313   => 230
-                    ,0x314   => 230
-                    ,0x33D   => 230
-                    ,0x33E   => 230
-                    ,0x33F   => 230
-                    ,0x340   => 230
-                    ,0x341   => 230
-                    ,0x342   => 230
-                    ,0x343   => 230
-                    ,0x344   => 230
-                    ,0x346   => 230
-                    ,0x34A   => 230
-                    ,0x34B   => 230
-                    ,0x34C   => 230
-                    ,0x350   => 230
-                    ,0x351   => 230
-                    ,0x352   => 230
-                    ,0x357   => 230
-                    ,0x363   => 230
-                    ,0x364   => 230
-                    ,0x365   => 230
-                    ,0x366   => 230
-                    ,0x367   => 230
-                    ,0x368   => 230
-                    ,0x369   => 230
-                    ,0x36A   => 230
-                    ,0x36B   => 230
-                    ,0x36C   => 230
-                    ,0x36D   => 230
-                    ,0x36E   => 230
-                    ,0x36F   => 230
-                    ,0x483   => 230
-                    ,0x484   => 230
-                    ,0x485   => 230
-                    ,0x486   => 230
-                    ,0x592   => 230
-                    ,0x593   => 230
-                    ,0x594   => 230
-                    ,0x595   => 230
-                    ,0x597   => 230
-                    ,0x598   => 230
-                    ,0x599   => 230
-                    ,0x59C   => 230
-                    ,0x59D   => 230
-                    ,0x59E   => 230
-                    ,0x59F   => 230
-                    ,0x5A0   => 230
-                    ,0x5A1   => 230
-                    ,0x5A8   => 230
-                    ,0x5A9   => 230
-                    ,0x5AB   => 230
-                    ,0x5AC   => 230
-                    ,0x5AF   => 230
-                    ,0x5C4   => 230
-                    ,0x610   => 230
-                    ,0x611   => 230
-                    ,0x612   => 230
-                    ,0x613   => 230
-                    ,0x614   => 230
-                    ,0x615   => 230
-                    ,0x653   => 230
-                    ,0x654   => 230
-                    ,0x657   => 230
-                    ,0x658   => 230
-                    ,0x6D6   => 230
-                    ,0x6D7   => 230
-                    ,0x6D8   => 230
-                    ,0x6D9   => 230
-                    ,0x6DA   => 230
-                    ,0x6DB   => 230
-                    ,0x6DC   => 230
-                    ,0x6DF   => 230
-                    ,0x6E0   => 230
-                    ,0x6E1   => 230
-                    ,0x6E2   => 230
-                    ,0x6E4   => 230
-                    ,0x6E7   => 230
-                    ,0x6E8   => 230
-                    ,0x6EB   => 230
-                    ,0x6EC   => 230
-                    ,0x730   => 230
-                    ,0x732   => 230
-                    ,0x733   => 230
-                    ,0x735   => 230
-                    ,0x736   => 230
-                    ,0x73A   => 230
-                    ,0x73D   => 230
-                    ,0x73F   => 230
-                    ,0x740   => 230
-                    ,0x741   => 230
-                    ,0x743   => 230
-                    ,0x745   => 230
-                    ,0x747   => 230
-                    ,0x749   => 230
-                    ,0x74A   => 230
-                    ,0x951   => 230
-                    ,0x953   => 230
-                    ,0x954   => 230
-                    ,0xF82   => 230
-                    ,0xF83   => 230
-                    ,0xF86   => 230
-                    ,0xF87   => 230
-                    ,0x170D  => 230
-                    ,0x193A  => 230
-                    ,0x20D0  => 230
-                    ,0x20D1  => 230
-                    ,0x20D4  => 230
-                    ,0x20D5  => 230
-                    ,0x20D6  => 230
-                    ,0x20D7  => 230
-                    ,0x20DB  => 230
-                    ,0x20DC  => 230
-                    ,0x20E1  => 230
-                    ,0x20E7  => 230
-                    ,0x20E9  => 230
-                    ,0xFE20  => 230
-                    ,0xFE21  => 230
-                    ,0xFE22  => 230
-                    ,0xFE23  => 230
-                    ,0x1D185 => 230
-                    ,0x1D186 => 230
-                    ,0x1D187 => 230
-                    ,0x1D189 => 230
-                    ,0x1D188 => 230
-                    ,0x1D1AA => 230
-                    ,0x1D1AB => 230
-                    ,0x1D1AC => 230
-                    ,0x1D1AD => 230
-                    ,0x315   => 232
-                    ,0x31A   => 232
-                    ,0x302C  => 232
-                    ,0x35F   => 233
-                    ,0x362   => 233
-                    ,0x35D   => 234
-                    ,0x35E   => 234
-                    ,0x360   => 234
-                    ,0x361   => 234
-                    ,0x345   => 240
-                    )
-            );
-}
-?>
\ No newline at end of file
+<?php
+// {{{ license
+
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
+//
+// +----------------------------------------------------------------------+
+// | This library is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU Lesser General Public License as       |
+// | published by the Free Software Foundation; either version 2.1 of the |
+// | License, or (at your option) any later version.                      |
+// |                                                                      |
+// | This library 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    |
+// | Lesser General Public License for more details.                      |
+// |                                                                      |
+// | You should have received a copy of the GNU Lesser General Public     |
+// | License along with this library; if not, write to the Free Software  |
+// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 |
+// | USA.                                                                 |
+// +----------------------------------------------------------------------+
+//
+
+// }}}
+
+/**
+ * Encode/decode Internationalized Domain Names.
+ *
+ * The class allows to convert internationalized domain names
+ * (see RFC 3490 for details) as they can be used with various registries worldwide
+ * to be translated between their original (localized) form and their encoded form
+ * as it will be used in the DNS (Domain Name System).
+ *
+ * The class provides two public methods, encode() and decode(), which do exactly
+ * what you would expect them to do. You are allowed to use complete domain names,
+ * simple strings and complete email addresses as well. That means, that you might
+ * use any of the following notations:
+ *
+ * - www.n�rgler.com
+ * - xn--nrgler-wxa
+ * - xn--brse-5qa.xn--knrz-1ra.info
+ *
+ * Unicode input might be given as either UTF-8 string, UCS-4 string or UCS-4
+ * array. Unicode output is available in the same formats.
+ * You can select your preferred format via {@link set_paramter()}.
+ *
+ * ACE input and output is always expected to be ASCII.
+ *
+ * @author  Matthias Sommerfeld <mso@phlylabs.de>
+ * @author  Leonid Kogan <lko@neuse.de>
+ * @copyright 2004-2008 phlyLabs Berlin, http://phlylabs.de
+ * @version 0.6.0
+ * @changelog since 0.5.1 class updated to PHP5/6 style should be compatible to PHP 4.3+
+ *
+ */
+class IDNA_Convert
+{
+    // NP See below
+
+    // Internal settings, do not mess with them
+    private $_punycode_prefix = 'xn--';
+    private $_invalid_ucs = 0x80000000;
+    private $_max_ucs = 0x10FFFF;
+    private $_base = 36;
+    private $_tmin = 1;
+    private $_tmax = 26;
+    private $_skew = 38;
+    private $_damp = 700;
+    private $_initial_bias = 72;
+    private $_initial_n = 0x80;
+    private $_sbase = 0xAC00;
+    private $_lbase = 0x1100;
+    private $_vbase = 0x1161;
+    private $_tbase = 0x11A7;
+    private $_lcount = 19;
+    private $_vcount = 21;
+    private $_tcount = 28;
+    private $_ncount = 588;   // _vcount * _tcount
+    private $_scount = 11172; // _lcount * _tcount * _vcount
+    private $_error = false;
+
+    // See {@link set_paramter()} for details of how to change the following
+    // settings from within your script / application
+    private $_api_encoding = 'utf8';  // Default input charset is UTF-8
+    private $_allow_overlong = false; // Overlong UTF-8 encodings are forbidden
+    private $_strict_mode = false;    // Behave strict or not
+
+
+    /**
+     * the constructor
+     *
+     * @param array $options
+     * @return boolean
+     * @since 0.5.2
+     */
+    public function __construct($options = false)
+    {
+        $this->slast = $this->_sbase + $this->_lcount * $this->_vcount * $this->_tcount;
+        // If parameters are given, pass these to the respective method
+        if (is_array($options)) return $this->set_parameter($options);
+        return true;
+    }
+
+    /**
+     * Sets a new option value. Available options and values:
+     * [encoding - Use either UTF-8, UCS4 as array or UCS4 as string as input ('utf8' for UTF-8,
+     *         'ucs4_string' and 'ucs4_array' respectively for UCS4); The output is always UTF-8]
+     * [overlong - Unicode does not allow unnecessarily long encodings of chars,
+     *             to allow this, set this parameter to true, else to false;
+     *             default is false.]
+     * [strict - true: strict mode, good for registration purposes - Causes errors
+     *           on failures; false: loose mode, ideal for "wildlife" applications
+     *           by silently ignoring errors and returning the original input instead
+     *
+     * @param    mixed     Parameter to set (string: single parameter; array of Parameter => Value pairs)
+     * @param    string    Value to use (if parameter 1 is a string)
+     * @return   boolean   true on success, false otherwise
+     */
+    public function set_parameter($option, $value = false)
+    {
+        if (!is_array($option)) {
+            $option = array($option => $value);
+        }
+        foreach ($option as $k => $v) {
+            switch ($k) {
+            case 'encoding':
+                switch ($v) {
+                case 'utf8':
+                case 'ucs4_string':
+                case 'ucs4_array':
+                    $this->_api_encoding = $v;
+                    break;
+                default:
+                    $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k);
+                    return false;
+                }
+                break;
+            case 'overlong':
+                $this->_allow_overlong = ($v) ? true : false;
+                break;
+            case 'strict':
+                $this->_strict_mode = ($v) ? true : false;
+                break;
+            default:
+                $this->_error('Set Parameter: Unknown option '.$k);
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Decode a given ACE domain name
+     * @param    string   Domain name (ACE string)
+     * [@param    string   Desired output encoding, see {@link set_parameter}]
+     * @return   string   Decoded Domain name (UTF-8 or UCS-4)
+     */
+    public function decode($input, $one_time_encoding = false)
+    {
+        // Optionally set
+        if ($one_time_encoding) {
+            switch ($one_time_encoding) {
+            case 'utf8':
+            case 'ucs4_string':
+            case 'ucs4_array':
+                break;
+            default:
+                $this->_error('Unknown encoding '.$one_time_encoding);
+                return false;
+            }
+        }
+        // Make sure to drop any newline characters around
+        $input = trim($input);
+
+        // Negotiate input and try to determine, whether it is a plain string,
+        // an email address or something like a complete URL
+        if (strpos($input, '@')) { // Maybe it is an email address
+            // No no in strict mode
+            if ($this->_strict_mode) {
+                $this->_error('Only simple domain name parts can be handled in strict mode');
+                return false;
+            }
+            list ($email_pref, $input) = explode('@', $input, 2);
+            $arr = explode('.', $input);
+            foreach ($arr as $k => $v) {
+                if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
+                    $conv = $this->_decode($v);
+                    if ($conv) $arr[$k] = $conv;
+                }
+            }
+            $input = join('.', $arr);
+            $arr = explode('.', $email_pref);
+            foreach ($arr as $k => $v) {
+                if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
+                    $conv = $this->_decode($v);
+                    if ($conv) $arr[$k] = $conv;
+                }
+            }
+            $email_pref = join('.', $arr);
+            $return = $email_pref . '@' . $input;
+        } elseif (preg_match('![:\./]!', $input)) { // Or a complete domain name (with or without paths / parameters)
+            // No no in strict mode
+            if ($this->_strict_mode) {
+                $this->_error('Only simple domain name parts can be handled in strict mode');
+                return false;
+            }
+            $parsed = parse_url($input);
+            if (isset($parsed['host'])) {
+                $arr = explode('.', $parsed['host']);
+                foreach ($arr as $k => $v) {
+                    $conv = $this->_decode($v);
+                    if ($conv) $arr[$k] = $conv;
+                }
+                $parsed['host'] = join('.', $arr);
+                $return =
+                        (empty($parsed['scheme']) ? '' : $parsed['scheme'].(strtolower($parsed['scheme']) == 'mailto' ? ':' : '://'))
+                        .(empty($parsed['user']) ? '' : $parsed['user'].(empty($parsed['pass']) ? '' : ':'.$parsed['pass']).'@')
+                        .$parsed['host']
+                        .(empty($parsed['port']) ? '' : ':'.$parsed['port'])
+                        .(empty($parsed['path']) ? '' : $parsed['path'])
+                        .(empty($parsed['query']) ? '' : '?'.$parsed['query'])
+                        .(empty($parsed['fragment']) ? '' : '#'.$parsed['fragment']);
+            } else { // parse_url seems to have failed, try without it
+                $arr = explode('.', $input);
+                foreach ($arr as $k => $v) {
+                    $conv = $this->_decode($v);
+                    $arr[$k] = ($conv) ? $conv : $v;
+                }
+                $return = join('.', $arr);
+            }
+        } else { // Otherwise we consider it being a pure domain name string
+            $return = $this->_decode($input);
+            if (!$return) $return = $input;
+        }
+        // The output is UTF-8 by default, other output formats need conversion here
+        // If one time encoding is given, use this, else the objects property
+        switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) {
+        case 'utf8':
+            return $return;
+            break;
+        case 'ucs4_string':
+           return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return));
+           break;
+        case 'ucs4_array':
+            return $this->_utf8_to_ucs4($return);
+            break;
+        default:
+            $this->_error('Unsupported output format');
+            return false;
+        }
+    }
+
+    /**
+     * Encode a given UTF-8 domain name
+     * @param    string   Domain name (UTF-8 or UCS-4)
+     * [@param    string   Desired input encoding, see {@link set_parameter}]
+     * @return   string   Encoded Domain name (ACE string)
+     */
+    public function encode($decoded, $one_time_encoding = false)
+    {
+        // Forcing conversion of input to UCS4 array
+        // If one time encoding is given, use this, else the objects property
+        switch ($one_time_encoding ? $one_time_encoding : $this->_api_encoding) {
+        case 'utf8':
+            $decoded = $this->_utf8_to_ucs4($decoded);
+            break;
+        case 'ucs4_string':
+           $decoded = $this->_ucs4_string_to_ucs4($decoded);
+        case 'ucs4_array':
+           break;
+        default:
+            $this->_error('Unsupported input format: '.($one_time_encoding ? $one_time_encoding : $this->_api_encoding));
+            return false;
+        }
+
+        // No input, no output, what else did you expect?
+        if (empty($decoded)) return '';
+
+        // Anchors for iteration
+        $last_begin = 0;
+        // Output string
+        $output = '';
+        foreach ($decoded as $k => $v) {
+            // Make sure to use just the plain dot
+            switch($v) {
+            case 0x3002:
+            case 0xFF0E:
+            case 0xFF61:
+                $decoded[$k] = 0x2E;
+                // Right, no break here, the above are converted to dots anyway
+            // Stumbling across an anchoring character
+            case 0x2E:
+            case 0x2F:
+            case 0x3A:
+            case 0x3F:
+            case 0x40:
+                // Neither email addresses nor URLs allowed in strict mode
+                if ($this->_strict_mode) {
+                   $this->_error('Neither email addresses nor URLs are allowed in strict mode.');
+                   return false;
+                } else {
+                    // Skip first char
+                    if ($k) {
+                        $encoded = '';
+                        $encoded = $this->_encode(array_slice($decoded, $last_begin, (($k)-$last_begin)));
+                        if ($encoded) {
+                            $output .= $encoded;
+                        } else {
+                            $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($k)-$last_begin)));
+                        }
+                        $output .= chr($decoded[$k]);
+                    }
+                    $last_begin = $k + 1;
+                }
+            }
+        }
+        // Catch the rest of the string
+        if ($last_begin && is_array($decoded)) {
+            $inp_len = sizeof($decoded);
+            $encoded = '';
+            $encoded = $this->_encode(array_slice($decoded, $last_begin, (($inp_len)-$last_begin)));
+            if ($encoded) {
+                $output .= $encoded;
+            } else {
+                $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($inp_len)-$last_begin)));
+            }
+            return $output;
+        } else {
+            if ($output = $this->_encode($decoded)) {
+                return $output;
+            } else {
+                return $this->_ucs4_to_utf8($decoded);
+            }
+        }
+    }
+
+    /**
+     * Use this method to get the last error ocurred
+     * @param    void
+     * @return   string   The last error, that occured
+     */
+    public function get_last_error()
+    {
+        return $this->_error;
+    }
+
+    /**
+     * The actual decoding algorithm
+     * @param string
+     * @return mixed
+     */
+    private function _decode($encoded)
+    {
+        $decoded = array();
+        // find the Punycode prefix
+        if (!preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $encoded)) {
+            $this->_error('This is not a punycode string');
+            return false;
+        }
+        $encode_test = preg_replace('!^'.preg_quote($this->_punycode_prefix, '!').'!', '', $encoded);
+        // If nothing left after removing the prefix, it is hopeless
+        if (!$encode_test) {
+            $this->_error('The given encoded string was empty');
+            return false;
+        }
+        // Find last occurence of the delimiter
+        $delim_pos = strrpos($encoded, '-');
+        if ($delim_pos > strlen($this->_punycode_prefix)) {
+            for ($k = strlen($this->_punycode_prefix); $k < $delim_pos; ++$k) {
+                $decoded[] = ord($encoded{$k});
+            }
+        }
+        $deco_len = count($decoded);
+        $enco_len = strlen($encoded);
+
+        // Wandering through the strings; init
+        $is_first = true;
+        $bias = $this->_initial_bias;
+        $idx = 0;
+        $char = $this->_initial_n;
+
+        for ($enco_idx = ($delim_pos) ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) {
+            for ($old_idx = $idx, $w = 1, $k = $this->_base; 1 ; $k += $this->_base) {
+                $digit = $this->_decode_digit($encoded{$enco_idx++});
+                $idx += $digit * $w;
+                $t = ($k <= $bias) ? $this->_tmin :
+                        (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias));
+                if ($digit < $t) break;
+                $w = (int) ($w * ($this->_base - $t));
+            }
+            $bias = $this->_adapt($idx - $old_idx, $deco_len + 1, $is_first);
+            $is_first = false;
+            $char += (int) ($idx / ($deco_len + 1));
+            $idx %= ($deco_len + 1);
+            if ($deco_len > 0) {
+                // Make room for the decoded char
+                for ($i = $deco_len; $i > $idx; $i--) $decoded[$i] = $decoded[($i - 1)];
+            }
+            $decoded[$idx++] = $char;
+        }
+        return $this->_ucs4_to_utf8($decoded);
+    }
+
+    /**
+     * The actual encoding algorithm
+     * @param  string
+     * @return mixed
+     */
+    private function _encode($decoded)
+    {
+        // We cannot encode a domain name containing the Punycode prefix
+        $extract = strlen($this->_punycode_prefix);
+        $check_pref = $this->_utf8_to_ucs4($this->_punycode_prefix);
+        $check_deco = array_slice($decoded, 0, $extract);
+
+        if ($check_pref == $check_deco) {
+            $this->_error('This is already a punycode string');
+            return false;
+        }
+        // We will not try to encode strings consisting of basic code points only
+        $encodable = false;
+        foreach ($decoded as $k => $v) {
+            if ($v > 0x7a) {
+                $encodable = true;
+                break;
+            }
+        }
+        if (!$encodable) {
+            $this->_error('The given string does not contain encodable chars');
+            return false;
+        }
+        // Do NAMEPREP
+        $decoded = $this->_nameprep($decoded);
+        if (!$decoded || !is_array($decoded)) return false; // NAMEPREP failed
+        $deco_len  = count($decoded);
+        if (!$deco_len) return false; // Empty array
+        $codecount = 0; // How many chars have been consumed
+        $encoded = '';
+        // Copy all basic code points to output
+        for ($i = 0; $i < $deco_len; ++$i) {
+            $test = $decoded[$i];
+            // Will match [-0-9a-zA-Z]
+            if ((0x2F < $test && $test < 0x40) || (0x40 < $test && $test < 0x5B)
+                    || (0x60 < $test && $test <= 0x7B) || (0x2D == $test)) {
+                $encoded .= chr($decoded[$i]);
+                $codecount++;
+            }
+        }
+        if ($codecount == $deco_len) return $encoded; // All codepoints were basic ones
+
+        // Start with the prefix; copy it to output
+        $encoded = $this->_punycode_prefix.$encoded;
+        // If we have basic code points in output, add an hyphen to the end
+        if ($codecount) $encoded .= '-';
+        // Now find and encode all non-basic code points
+        $is_first = true;
+        $cur_code = $this->_initial_n;
+        $bias = $this->_initial_bias;
+        $delta = 0;
+        while ($codecount < $deco_len) {
+            // Find the smallest code point >= the current code point and
+            // remember the last ouccrence of it in the input
+            for ($i = 0, $next_code = $this->_max_ucs; $i < $deco_len; $i++) {
+                if ($decoded[$i] >= $cur_code && $decoded[$i] <= $next_code) {
+                    $next_code = $decoded[$i];
+                }
+            }
+            $delta += ($next_code - $cur_code) * ($codecount + 1);
+            $cur_code = $next_code;
+
+            // Scan input again and encode all characters whose code point is $cur_code
+            for ($i = 0; $i < $deco_len; $i++) {
+                if ($decoded[$i] < $cur_code) {
+                    $delta++;
+                } elseif ($decoded[$i] == $cur_code) {
+                    for ($q = $delta, $k = $this->_base; 1; $k += $this->_base) {
+                        $t = ($k <= $bias) ? $this->_tmin :
+                                (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias);
+                        if ($q < $t) break;
+                        $encoded .= $this->_encode_digit(intval($t + (($q - $t) % ($this->_base - $t)))); //v0.4.5 Changed from ceil() to intval()
+                        $q = (int) (($q - $t) / ($this->_base - $t));
+                    }
+                    $encoded .= $this->_encode_digit($q);
+                    $bias = $this->_adapt($delta, $codecount+1, $is_first);
+                    $codecount++;
+                    $delta = 0;
+                    $is_first = false;
+                }
+            }
+            $delta++;
+            $cur_code++;
+        }
+        return $encoded;
+    }
+
+    /**
+     * Adapt the bias according to the current code point and position
+     * @param int $delta
+     * @param int $npoints
+     * @param int $is_first
+     * @return int
+     */
+    private function _adapt($delta, $npoints, $is_first)
+    {
+        $delta = intval($is_first ? ($delta / $this->_damp) : ($delta / 2));
+        $delta += intval($delta / $npoints);
+        for ($k = 0; $delta > (($this->_base - $this->_tmin) * $this->_tmax) / 2; $k += $this->_base) {
+            $delta = intval($delta / ($this->_base - $this->_tmin));
+        }
+        return intval($k + ($this->_base - $this->_tmin + 1) * $delta / ($delta + $this->_skew));
+    }
+
+    /**
+     * Encoding a certain digit
+     * @param    int $d
+     * @return string
+     */
+    private function _encode_digit($d)
+    {
+        return chr($d + 22 + 75 * ($d < 26));
+    }
+
+    /**
+     * Decode a certain digit
+     * @param    int $cp
+     * @return int
+     */
+    private function _decode_digit($cp)
+    {
+        $cp = ord($cp);
+        return ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $this->_base));
+    }
+
+    /**
+     * Internal error handling method
+     * @param  string $error
+     */
+    private function _error($error = '')
+    {
+        $this->_error = $error;
+    }
+
+    /**
+     * Do Nameprep according to RFC3491 and RFC3454
+     * @param    array    Unicode Characters
+     * @return   string   Unicode Characters, Nameprep'd
+     */
+    private function _nameprep($input)
+    {
+        $output = array();
+        $error = false;
+        //
+        // Mapping
+        // Walking through the input array, performing the required steps on each of
+        // the input chars and putting the result into the output array
+        // While mapping required chars we apply the cannonical ordering
+        foreach ($input as $v) {
+            // Map to nothing == skip that code point
+            if (in_array($v, $this->NP['map_nothing'])) continue;
+            // Try to find prohibited input
+            if (in_array($v, $this->NP['prohibit']) || in_array($v, $this->NP['general_prohibited'])) {
+                $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
+                return false;
+            }
+            foreach ($this->NP['prohibit_ranges'] as $range) {
+                if ($range[0] <= $v && $v <= $range[1]) {
+                    $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
+                    return false;
+                }
+            }
+            // Hangul syllable decomposition
+            if (0xAC00 <= $v && $v <= 0xD7AF) {
+                foreach ($this->_hangul_decompose($v) as $out) $output[] = (int) $out;
+            // There's a decomposition mapping for that code point
+            } elseif (isset($this->NP['replacemaps'][$v])) {
+                foreach ($this->_apply_cannonical_ordering($this->NP['replacemaps'][$v]) as $out) {
+                    $output[] = (int) $out;
+                }
+            } else {
+                $output[] = (int) $v;
+            }
+        }
+        // Before applying any Combining, try to rearrange any Hangul syllables
+        $output = $this->_hangul_compose($output);
+        //
+        // Combine code points
+        //
+        $last_class = 0;
+        $last_starter = 0;
+        $out_len = count($output);
+        for ($i = 0; $i < $out_len; ++$i) {
+            $class = $this->_get_combining_class($output[$i]);
+            if ((!$last_class || $last_class > $class) && $class) {
+                // Try to match
+                $seq_len = $i - $last_starter;
+                $out = $this->_combine(array_slice($output, $last_starter, $seq_len));
+                // On match: Replace the last starter with the composed character and remove
+                // the now redundant non-starter(s)
+                if ($out) {
+                    $output[$last_starter] = $out;
+                    if (is_array($out) && count($out) !== $seq_len) {
+                        for ($j = $i+1; $j < $out_len; ++$j) $output[$j-1] = $output[$j];
+                        unset($output[$out_len]);
+                    }
+                    // Rewind the for loop by one, since there can be more possible compositions
+                    $i--;
+                    $out_len--;
+                    $last_class = ($i == $last_starter) ? 0 : $this->_get_combining_class($output[$i-1]);
+                    continue;
+                }
+            }
+            // The current class is 0
+            if (!$class) $last_starter = $i;
+            $last_class = $class;
+        }
+        return $output;
+    }
+
+    /**
+     * Decomposes a Hangul syllable
+     * (see http://www.unicode.org/unicode/reports/tr15/#Hangul
+     * @param    integer  32bit UCS4 code point
+     * @return   array    Either Hangul Syllable decomposed or original 32bit value as one value array
+     */
+    private function _hangul_decompose($char)
+    {
+        $sindex = (int) $char - $this->_sbase;
+        if ($sindex < 0 || $sindex >= $this->_scount) return array($char);
+        $result = array();
+        $result[] = (int) $this->_lbase + $sindex / $this->_ncount;
+        $result[] = (int) $this->_vbase + ($sindex % $this->_ncount) / $this->_tcount;
+        $T = intval($this->_tbase + $sindex % $this->_tcount);
+        if ($T != $this->_tbase) $result[] = $T;
+        return $result;
+    }
+    /**
+     * Ccomposes a Hangul syllable
+     * (see http://www.unicode.org/unicode/reports/tr15/#Hangul
+     * @param    array    Decomposed UCS4 sequence
+     * @return   array    UCS4 sequence with syllables composed
+     */
+    private function _hangul_compose($input)
+    {
+        $inp_len = is_array($input) ? count($input) : 0;
+        if (!$inp_len) return array();
+        $result = array();
+        $last = (int) $input[0];
+        $result[] = $last; // copy first char from input to output
+
+        for ($i = 1; $i < $inp_len; ++$i) {
+            $char = (int) $input[$i];
+            $sindex = $last - $this->_sbase;
+            $lindex = $last - $this->_lbase;
+            $vindex = $char - $this->_vbase;
+            $tindex = $char - $this->_tbase;
+            // Find out, whether two current characters are LV and T
+            if (0 <= $sindex && $sindex < $this->_scount && ($sindex % $this->_tcount == 0)
+                    && 0 <= $tindex && $tindex <= $this->_tcount) {
+                // create syllable of form LVT
+                $last += $tindex;
+                $result[(count($result) - 1)] = $last; // reset last
+                continue; // discard char
+            }
+            // Find out, whether two current characters form L and V
+            if (0 <= $lindex && $lindex < $this->_lcount && 0 <= $vindex && $vindex < $this->_vcount) {
+                // create syllable of form LV
+                $last = (int) $this->_sbase + ($lindex * $this->_vcount + $vindex) * $this->_tcount;
+                $result[(count($result) - 1)] = $last; // reset last
+                continue; // discard char
+            }
+            // if neither case was true, just add the character
+            $last = $char;
+            $result[] = $char;
+        }
+        return $result;
+    }
+
+    /**
+     * Returns the combining class of a certain wide char
+     * @param    integer    Wide char to check (32bit integer)
+     * @return   integer    Combining class if found, else 0
+     */
+    private function _get_combining_class($char)
+    {
+        return isset($this->NP['norm_combcls'][$char]) ? $this->NP['norm_combcls'][$char] : 0;
+    }
+
+    /**
+     * Apllies the cannonical ordering of a decomposed UCS4 sequence
+     * @param    array      Decomposed UCS4 sequence
+     * @return   array      Ordered USC4 sequence
+     */
+    private function _apply_cannonical_ordering($input)
+    {
+        $swap = true;
+        $size = is_array($input) ? count($input) : 0;
+        while ($swap) {
+            $swap = false;
+            $last = $this->_get_combining_class(intval($input[0]));
+            for ($i = 0; $i < $size-1; ++$i) {
+                $next = $this->_get_combining_class(intval($input[$i+1]));
+                if ($next != 0 && $last > $next) {
+                    // Move item leftward until it fits
+                    for ($j = $i + 1; $j > 0; --$j) {
+                        if ($this->_get_combining_class(intval($input[$j-1])) <= $next) break;
+                        $t = intval($input[$j]);
+                        $input[$j] = intval($input[$j-1]);
+                        $input[$j-1] = $t;
+                        $swap = true;
+                    }
+                    // Reentering the loop looking at the old character again
+                    $next = $last;
+                }
+                $last = $next;
+            }
+        }
+        return $input;
+    }
+
+    /**
+     * Do composition of a sequence of starter and non-starter
+     * @param    array      UCS4 Decomposed sequence
+     * @return   array      Ordered USC4 sequence
+     */
+    private function _combine($input)
+    {
+        $inp_len = is_array($input) ? count($input) : 0;
+        foreach ($this->NP['replacemaps'] as $np_src => $np_target) {
+            if ($np_target[0] != $input[0]) continue;
+            if (!is_array($np_target) || count($np_target) !== $inp_len) continue;
+            $hit = false;
+            foreach ($input as $k2 => $v2) {
+                if ($v2 == $np_target[$k2]) {
+                    $hit = true;
+                } else {
+                    $hit = false;
+                    break;
+                }
+            }
+            if ($hit) return $np_src;
+        }
+        return false;
+    }
+
+    /**
+     * This converts an UTF-8 encoded string to its UCS-4 representation
+     * By talking about UCS-4 "strings" we mean arrays of 32bit integers representing
+     * each of the "chars". This is due to PHP not being able to handle strings with
+     * bit depth different from 8. This apllies to the reverse method _ucs4_to_utf8(), too.
+     * The following UTF-8 encodings are supported:
+     * bytes bits  representation
+     * 1        7  0xxxxxxx
+     * 2       11  110xxxxx 10xxxxxx
+     * 3       16  1110xxxx 10xxxxxx 10xxxxxx
+     * 4       21  11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+     * 5       26  111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
+     * 6       31  1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
+     * Each x represents a bit that can be used to store character data.
+     * The five and six byte sequences are part of Annex D of ISO/IEC 10646-1:2000
+     * @param string $input
+     * @return string
+     */
+    private function _utf8_to_ucs4($input)
+    {
+        $output = array();
+        $out_len = 0;
+        $inp_len = strlen($input);
+        $mode = 'next';
+        $test = 'none';
+        for ($k = 0; $k < $inp_len; ++$k) {
+            $v = ord($input{$k}); // Extract byte from input string
+            if ($v < 128) { // We found an ASCII char - put into stirng as is
+                $output[$out_len] = $v;
+                ++$out_len;
+                if ('add' == $mode) {
+                    $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
+                    return false;
+                }
+                continue;
+            }
+            if ('next' == $mode) { // Try to find the next start byte; determine the width of the Unicode char
+                $start_byte = $v;
+                $mode = 'add';
+                $test = 'range';
+                if ($v >> 5 == 6) { // &110xxxxx 10xxxxx
+                    $next_byte = 0; // Tells, how many times subsequent bitmasks must rotate 6bits to the left
+                    $v = ($v - 192) << 6;
+                } elseif ($v >> 4 == 14) { // &1110xxxx 10xxxxxx 10xxxxxx
+                    $next_byte = 1;
+                    $v = ($v - 224) << 12;
+                } elseif ($v >> 3 == 30) { // &11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+                    $next_byte = 2;
+                    $v = ($v - 240) << 18;
+                } elseif ($v >> 2 == 62) { // &111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
+                    $next_byte = 3;
+                    $v = ($v - 248) << 24;
+                } elseif ($v >> 1 == 126) { // &1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
+                    $next_byte = 4;
+                    $v = ($v - 252) << 30;
+                } else {
+                    $this->_error('This might be UTF-8, but I don\'t understand it at byte '.$k);
+                    return false;
+                }
+                if ('add' == $mode) {
+                    $output[$out_len] = (int) $v;
+                    ++$out_len;
+                    continue;
+                }
+            }
+            if ('add' == $mode) {
+                if (!$this->_allow_overlong && $test == 'range') {
+                    $test = 'none';
+                    if (($v < 0xA0 && $start_byte == 0xE0) || ($v < 0x90 && $start_byte == 0xF0) || ($v > 0x8F && $start_byte == 0xF4)) {
+                        $this->_error('Bogus UTF-8 character detected (out of legal range) at byte '.$k);
+                        return false;
+                    }
+                }
+                if ($v >> 6 == 2) { // Bit mask must be 10xxxxxx
+                    $v = ($v - 128) << ($next_byte * 6);
+                    $output[($out_len - 1)] += $v;
+                    --$next_byte;
+                } else {
+                    $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
+                    return false;
+                }
+                if ($next_byte < 0) {
+                    $mode = 'next';
+                }
+            }
+        } // for
+        return $output;
+    }
+
+    /**
+     * Convert UCS-4 string into UTF-8 string
+     * See _utf8_to_ucs4() for details
+     * @param string  $input
+     * @return string
+     */
+    private function _ucs4_to_utf8($input)
+    {
+        $output = '';
+        foreach ($input as $v) {
+            if ($v < 128) { // 7bit are transferred literally
+                $output .= chr($v);
+            } elseif ($v < (1 << 11)) { // 2 bytes
+                $output .= chr(192+($v >> 6)).chr(128+($v & 63));
+            } elseif ($v < (1 << 16)) { // 3 bytes
+                $output .= chr(224+($v >> 12)).chr(128+(($v >> 6) & 63)).chr(128+($v & 63));
+            } elseif ($v < (1 << 21)) { // 4 bytes
+                $output .= chr(240+($v >> 18)).chr(128+(($v >> 12) & 63)).chr(128+(($v >> 6) & 63)).chr(128+($v & 63));
+            } elseif (self::$safe_mode) {
+                $output .= self::$safe_char;
+            } else {
+                $this->_error('Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k);
+                return false;
+            }
+        }
+        return $output;
+    }
+
+    /**
+      * Convert UCS-4 array into UCS-4 string
+      *
+      * @param array $input
+      * @return string
+      */
+    private function _ucs4_to_ucs4_string($input)
+    {
+        $output = '';
+        // Take array values and split output to 4 bytes per value
+        // The bit mask is 255, which reads &11111111
+        foreach ($input as $v) {
+            $output .= chr(($v >> 24) & 255).chr(($v >> 16) & 255).chr(($v >> 8) & 255).chr($v & 255);
+        }
+        return $output;
+    }
+
+    /**
+      * Convert UCS-4 strin into UCS-4 garray
+      *
+      * @param  string $input
+      * @return array
+      */
+    private function _ucs4_string_to_ucs4($input)
+    {
+        $output = array();
+        $inp_len = strlen($input);
+        // Input length must be dividable by 4
+        if ($inp_len % 4) {
+            $this->_error('Input UCS4 string is broken');
+            return false;
+        }
+        // Empty input - return empty output
+        if (!$inp_len) return $output;
+        for ($i = 0, $out_len = -1; $i < $inp_len; ++$i) {
+            // Increment output position every 4 input bytes
+            if (!($i % 4)) {
+                $out_len++;
+                $output[$out_len] = 0;
+            }
+            $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) );
+        }
+        return $output;
+    }
+
+    /**
+     * Holds all relevant mapping tables, loaded from a seperate file on construct
+     * See RFC3454 for details
+     *
+     * @private array
+     * @since 0.5.2
+     *
+     */
+    private $NP = array
+            ('map_nothing' => array
+                    (0xAD, 0x34F, 0x1806, 0x180B, 0x180C, 0x180D, 0x200B
+                    ,0x200C, 0x200D, 0x2060, 0xFE00, 0xFE01, 0xFE02, 0xFE03
+                    ,0xFE04, 0xFE05, 0xFE06, 0xFE07, 0xFE08, 0xFE09, 0xFE0A
+                    ,0xFE0B, 0xFE0C, 0xFE0D, 0xFE0E, 0xFE0F, 0xFEFF
+                    )
+            ,'general_prohibited' => array
+                    (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE
+                    ,0xF, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17
+                    ,0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20
+                    ,0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29
+                    ,0x2A, 0x2B, 0x2C, 0x2F, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F
+                    ,0x40, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x7B, 0x7C
+                    ,0x7D, 0x7E, 0x7F, 0x3002
+                    )
+            ,'prohibit' => array
+                    (0xA0, 0x340, 0x341, 0x6DD, 0x70F, 0x1680, 0x180E, 0x2000
+                    ,0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007
+                    ,0x2008, 0x2009, 0x200A, 0x200B, 0x200C, 0x200D, 0x200E
+                    ,0x200F, 0x2028, 0x2029, 0x202A, 0x202B, 0x202C, 0x202D
+                    ,0x202E, 0x202F, 0x205F, 0x206A, 0x206B, 0x206C, 0x206D
+                    ,0x206E, 0x206F, 0x3000, 0xFEFF, 0xFFF9, 0xFFFA, 0xFFFB
+                    ,0xFFFC, 0xFFFD, 0xFFFE, 0xFFFF, 0x1FFFE, 0x1FFFF, 0x2FFFE
+                    ,0x2FFFF, 0x3FFFE, 0x3FFFF, 0x4FFFE, 0x4FFFF, 0x5FFFE
+                    ,0x5FFFF, 0x6FFFE, 0x6FFFF, 0x7FFFE, 0x7FFFF, 0x8FFFE
+                    ,0x8FFFF, 0x9FFFE, 0x9FFFF, 0xAFFFE, 0xAFFFF, 0xBFFFE
+                    ,0xBFFFF, 0xCFFFE, 0xCFFFF, 0xDFFFE, 0xDFFFF, 0xE0001
+                    ,0xEFFFE, 0xEFFFF, 0xFFFFE, 0xFFFFF, 0x10FFFE, 0x10FFFF
+                    )
+            ,'prohibit_ranges' => array
+                    (array(0x80, 0x9F), array(0x2060, 0x206F)
+                    ,array(0x1D173, 0x1D17A), array(0xE000, 0xF8FF)
+                    ,array(0xF0000, 0xFFFFD), array(0x100000, 0x10FFFD)
+                    ,array(0xFDD0, 0xFDEF), array(0xD800, 0xDFFF)
+                    ,array(0x2FF0, 0x2FFB), array(0xE0020, 0xE007F)
+                    )
+            ,'replacemaps' => array
+                    (0x41 => array(0x61)
+                    ,0x42 => array(0x62)
+                    ,0x43 => array(0x63)
+                    ,0x44 => array(0x64)
+                    ,0x45 => array(0x65)
+                    ,0x46 => array(0x66)
+                    ,0x47 => array(0x67)
+                    ,0x48 => array(0x68)
+                    ,0x49 => array(0x69)
+                    ,0x4A => array(0x6A)
+                    ,0x4B => array(0x6B)
+                    ,0x4C => array(0x6C)
+                    ,0x4D => array(0x6D)
+                    ,0x4E => array(0x6E)
+                    ,0x4F => array(0x6F)
+                    ,0x50 => array(0x70)
+                    ,0x51 => array(0x71)
+                    ,0x52 => array(0x72)
+                    ,0x53 => array(0x73)
+                    ,0x54 => array(0x74)
+                    ,0x55 => array(0x75)
+                    ,0x56 => array(0x76)
+                    ,0x57 => array(0x77)
+                    ,0x58 => array(0x78)
+                    ,0x59 => array(0x79)
+                    ,0x5A => array(0x7A)
+                    ,0xB5 => array(0x3BC)
+                    ,0xC0 => array(0xE0)
+                    ,0xC1 => array(0xE1)
+                    ,0xC2 => array(0xE2)
+                    ,0xC3 => array(0xE3)
+                    ,0xC4 => array(0xE4)
+                    ,0xC5 => array(0xE5)
+                    ,0xC6 => array(0xE6)
+                    ,0xC7 => array(0xE7)
+                    ,0xC8 => array(0xE8)
+                    ,0xC9 => array(0xE9)
+                    ,0xCA => array(0xEA)
+                    ,0xCB => array(0xEB)
+                    ,0xCC => array(0xEC)
+                    ,0xCD => array(0xED)
+                    ,0xCE => array(0xEE)
+                    ,0xCF => array(0xEF)
+                    ,0xD0 => array(0xF0)
+                    ,0xD1 => array(0xF1)
+                    ,0xD2 => array(0xF2)
+                    ,0xD3 => array(0xF3)
+                    ,0xD4 => array(0xF4)
+                    ,0xD5 => array(0xF5)
+                    ,0xD6 => array(0xF6)
+                    ,0xD8 => array(0xF8)
+                    ,0xD9 => array(0xF9)
+                    ,0xDA => array(0xFA)
+                    ,0xDB => array(0xFB)
+                    ,0xDC => array(0xFC)
+                    ,0xDD => array(0xFD)
+                    ,0xDE => array(0xFE)
+                    ,0xDF => array(0x73, 0x73)
+                    ,0x100 => array(0x101)
+                    ,0x102 => array(0x103)
+                    ,0x104 => array(0x105)
+                    ,0x106 => array(0x107)
+                    ,0x108 => array(0x109)
+                    ,0x10A => array(0x10B)
+                    ,0x10C => array(0x10D)
+                    ,0x10E => array(0x10F)
+                    ,0x110 => array(0x111)
+                    ,0x112 => array(0x113)
+                    ,0x114 => array(0x115)
+                    ,0x116 => array(0x117)
+                    ,0x118 => array(0x119)
+                    ,0x11A => array(0x11B)
+                    ,0x11C => array(0x11D)
+                    ,0x11E => array(0x11F)
+                    ,0x120 => array(0x121)
+                    ,0x122 => array(0x123)
+                    ,0x124 => array(0x125)
+                    ,0x126 => array(0x127)
+                    ,0x128 => array(0x129)
+                    ,0x12A => array(0x12B)
+                    ,0x12C => array(0x12D)
+                    ,0x12E => array(0x12F)
+                    ,0x130 => array(0x69, 0x307)
+                    ,0x132 => array(0x133)
+                    ,0x134 => array(0x135)
+                    ,0x136 => array(0x137)
+                    ,0x139 => array(0x13A)
+                    ,0x13B => array(0x13C)
+                    ,0x13D => array(0x13E)
+                    ,0x13F => array(0x140)
+                    ,0x141 => array(0x142)
+                    ,0x143 => array(0x144)
+                    ,0x145 => array(0x146)
+                    ,0x147 => array(0x148)
+                    ,0x149 => array(0x2BC, 0x6E)
+                    ,0x14A => array(0x14B)
+                    ,0x14C => array(0x14D)
+                    ,0x14E => array(0x14F)
+                    ,0x150 => array(0x151)
+                    ,0x152 => array(0x153)
+                    ,0x154 => array(0x155)
+                    ,0x156 => array(0x157)
+                    ,0x158 => array(0x159)
+                    ,0x15A => array(0x15B)
+                    ,0x15C => array(0x15D)
+                    ,0x15E => array(0x15F)
+                    ,0x160 => array(0x161)
+                    ,0x162 => array(0x163)
+                    ,0x164 => array(0x165)
+                    ,0x166 => array(0x167)
+                    ,0x168 => array(0x169)
+                    ,0x16A => array(0x16B)
+                    ,0x16C => array(0x16D)
+                    ,0x16E => array(0x16F)
+                    ,0x170 => array(0x171)
+                    ,0x172 => array(0x173)
+                    ,0x174 => array(0x175)
+                    ,0x176 => array(0x177)
+                    ,0x178 => array(0xFF)
+                    ,0x179 => array(0x17A)
+                    ,0x17B => array(0x17C)
+                    ,0x17D => array(0x17E)
+                    ,0x17F => array(0x73)
+                    ,0x181 => array(0x253)
+                    ,0x182 => array(0x183)
+                    ,0x184 => array(0x185)
+                    ,0x186 => array(0x254)
+                    ,0x187 => array(0x188)
+                    ,0x189 => array(0x256)
+                    ,0x18A => array(0x257)
+                    ,0x18B => array(0x18C)
+                    ,0x18E => array(0x1DD)
+                    ,0x18F => array(0x259)
+                    ,0x190 => array(0x25B)
+                    ,0x191 => array(0x192)
+                    ,0x193 => array(0x260)
+                    ,0x194 => array(0x263)
+                    ,0x196 => array(0x269)
+                    ,0x197 => array(0x268)
+                    ,0x198 => array(0x199)
+                    ,0x19C => array(0x26F)
+                    ,0x19D => array(0x272)
+                    ,0x19F => array(0x275)
+                    ,0x1A0 => array(0x1A1)
+                    ,0x1A2 => array(0x1A3)
+                    ,0x1A4 => array(0x1A5)
+                    ,0x1A6 => array(0x280)
+                    ,0x1A7 => array(0x1A8)
+                    ,0x1A9 => array(0x283)
+                    ,0x1AC => array(0x1AD)
+                    ,0x1AE => array(0x288)
+                    ,0x1AF => array(0x1B0)
+                    ,0x1B1 => array(0x28A)
+                    ,0x1B2 => array(0x28B)
+                    ,0x1B3 => array(0x1B4)
+                    ,0x1B5 => array(0x1B6)
+                    ,0x1B7 => array(0x292)
+                    ,0x1B8 => array(0x1B9)
+                    ,0x1BC => array(0x1BD)
+                    ,0x1C4 => array(0x1C6)
+                    ,0x1C5 => array(0x1C6)
+                    ,0x1C7 => array(0x1C9)
+                    ,0x1C8 => array(0x1C9)
+                    ,0x1CA => array(0x1CC)
+                    ,0x1CB => array(0x1CC)
+                    ,0x1CD => array(0x1CE)
+                    ,0x1CF => array(0x1D0)
+                    ,0x1D1   => array(0x1D2)
+                    ,0x1D3   => array(0x1D4)
+                    ,0x1D5   => array(0x1D6)
+                    ,0x1D7   => array(0x1D8)
+                    ,0x1D9   => array(0x1DA)
+                    ,0x1DB   => array(0x1DC)
+                    ,0x1DE   => array(0x1DF)
+                    ,0x1E0   => array(0x1E1)
+                    ,0x1E2   => array(0x1E3)
+                    ,0x1E4   => array(0x1E5)
+                    ,0x1E6   => array(0x1E7)
+                    ,0x1E8   => array(0x1E9)
+                    ,0x1EA   => array(0x1EB)
+                    ,0x1EC   => array(0x1ED)
+                    ,0x1EE   => array(0x1EF)
+                    ,0x1F0   => array(0x6A, 0x30C)
+                    ,0x1F1   => array(0x1F3)
+                    ,0x1F2   => array(0x1F3)
+                    ,0x1F4   => array(0x1F5)
+                    ,0x1F6   => array(0x195)
+                    ,0x1F7   => array(0x1BF)
+                    ,0x1F8   => array(0x1F9)
+                    ,0x1FA   => array(0x1FB)
+                    ,0x1FC   => array(0x1FD)
+                    ,0x1FE   => array(0x1FF)
+                    ,0x200   => array(0x201)
+                    ,0x202   => array(0x203)
+                    ,0x204   => array(0x205)
+                    ,0x206   => array(0x207)
+                    ,0x208   => array(0x209)
+                    ,0x20A   => array(0x20B)
+                    ,0x20C   => array(0x20D)
+                    ,0x20E   => array(0x20F)
+                    ,0x210   => array(0x211)
+                    ,0x212   => array(0x213)
+                    ,0x214   => array(0x215)
+                    ,0x216   => array(0x217)
+                    ,0x218   => array(0x219)
+                    ,0x21A   => array(0x21B)
+                    ,0x21C   => array(0x21D)
+                    ,0x21E   => array(0x21F)
+                    ,0x220   => array(0x19E)
+                    ,0x222   => array(0x223)
+                    ,0x224   => array(0x225)
+                    ,0x226   => array(0x227)
+                    ,0x228   => array(0x229)
+                    ,0x22A   => array(0x22B)
+                    ,0x22C   => array(0x22D)
+                    ,0x22E   => array(0x22F)
+                    ,0x230   => array(0x231)
+                    ,0x232   => array(0x233)
+                    ,0x345   => array(0x3B9)
+                    ,0x37A   => array(0x20, 0x3B9)
+                    ,0x386   => array(0x3AC)
+                    ,0x388   => array(0x3AD)
+                    ,0x389   => array(0x3AE)
+                    ,0x38A   => array(0x3AF)
+                    ,0x38C   => array(0x3CC)
+                    ,0x38E   => array(0x3CD)
+                    ,0x38F   => array(0x3CE)
+                    ,0x390   => array(0x3B9, 0x308, 0x301)
+                    ,0x391   => array(0x3B1)
+                    ,0x392   => array(0x3B2)
+                    ,0x393   => array(0x3B3)
+                    ,0x394   => array(0x3B4)
+                    ,0x395   => array(0x3B5)
+                    ,0x396   => array(0x3B6)
+                    ,0x397   => array(0x3B7)
+                    ,0x398   => array(0x3B8)
+                    ,0x399   => array(0x3B9)
+                    ,0x39A   => array(0x3BA)
+                    ,0x39B   => array(0x3BB)
+                    ,0x39C   => array(0x3BC)
+                    ,0x39D   => array(0x3BD)
+                    ,0x39E   => array(0x3BE)
+                    ,0x39F   => array(0x3BF)
+                    ,0x3A0   => array(0x3C0)
+                    ,0x3A1   => array(0x3C1)
+                    ,0x3A3   => array(0x3C3)
+                    ,0x3A4   => array(0x3C4)
+                    ,0x3A5   => array(0x3C5)
+                    ,0x3A6   => array(0x3C6)
+                    ,0x3A7   => array(0x3C7)
+                    ,0x3A8   => array(0x3C8)
+                    ,0x3A9   => array(0x3C9)
+                    ,0x3AA   => array(0x3CA)
+                    ,0x3AB   => array(0x3CB)
+                    ,0x3B0   => array(0x3C5, 0x308, 0x301)
+                    ,0x3C2   => array(0x3C3)
+                    ,0x3D0   => array(0x3B2)
+                    ,0x3D1   => array(0x3B8)
+                    ,0x3D2   => array(0x3C5)
+                    ,0x3D3   => array(0x3CD)
+                    ,0x3D4   => array(0x3CB)
+                    ,0x3D5   => array(0x3C6)
+                    ,0x3D6   => array(0x3C0)
+                    ,0x3D8   => array(0x3D9)
+                    ,0x3DA   => array(0x3DB)
+                    ,0x3DC   => array(0x3DD)
+                    ,0x3DE   => array(0x3DF)
+                    ,0x3E0   => array(0x3E1)
+                    ,0x3E2   => array(0x3E3)
+                    ,0x3E4   => array(0x3E5)
+                    ,0x3E6   => array(0x3E7)
+                    ,0x3E8   => array(0x3E9)
+                    ,0x3EA   => array(0x3EB)
+                    ,0x3EC   => array(0x3ED)
+                    ,0x3EE   => array(0x3EF)
+                    ,0x3F0   => array(0x3BA)
+                    ,0x3F1   => array(0x3C1)
+                    ,0x3F2   => array(0x3C3)
+                    ,0x3F4   => array(0x3B8)
+                    ,0x3F5   => array(0x3B5)
+                    ,0x400   => array(0x450)
+                    ,0x401   => array(0x451)
+                    ,0x402   => array(0x452)
+                    ,0x403   => array(0x453)
+                    ,0x404   => array(0x454)
+                    ,0x405   => array(0x455)
+                    ,0x406   => array(0x456)
+                    ,0x407   => array(0x457)
+                    ,0x408   => array(0x458)
+                    ,0x409   => array(0x459)
+                    ,0x40A   => array(0x45A)
+                    ,0x40B   => array(0x45B)
+                    ,0x40C   => array(0x45C)
+                    ,0x40D   => array(0x45D)
+                    ,0x40E   => array(0x45E)
+                    ,0x40F   => array(0x45F)
+                    ,0x410   => array(0x430)
+                    ,0x411   => array(0x431)
+                    ,0x412   => array(0x432)
+                    ,0x413   => array(0x433)
+                    ,0x414   => array(0x434)
+                    ,0x415   => array(0x435)
+                    ,0x416   => array(0x436)
+                    ,0x417   => array(0x437)
+                    ,0x418   => array(0x438)
+                    ,0x419   => array(0x439)
+                    ,0x41A   => array(0x43A)
+                    ,0x41B   => array(0x43B)
+                    ,0x41C   => array(0x43C)
+                    ,0x41D   => array(0x43D)
+                    ,0x41E   => array(0x43E)
+                    ,0x41F   => array(0x43F)
+                    ,0x420   => array(0x440)
+                    ,0x421   => array(0x441)
+                    ,0x422   => array(0x442)
+                    ,0x423   => array(0x443)
+                    ,0x424   => array(0x444)
+                    ,0x425   => array(0x445)
+                    ,0x426   => array(0x446)
+                    ,0x427   => array(0x447)
+                    ,0x428   => array(0x448)
+                    ,0x429   => array(0x449)
+                    ,0x42A   => array(0x44A)
+                    ,0x42B   => array(0x44B)
+                    ,0x42C   => array(0x44C)
+                    ,0x42D   => array(0x44D)
+                    ,0x42E   => array(0x44E)
+                    ,0x42F   => array(0x44F)
+                    ,0x460   => array(0x461)
+                    ,0x462   => array(0x463)
+                    ,0x464   => array(0x465)
+                    ,0x466   => array(0x467)
+                    ,0x468   => array(0x469)
+                    ,0x46A   => array(0x46B)
+                    ,0x46C   => array(0x46D)
+                    ,0x46E   => array(0x46F)
+                    ,0x470   => array(0x471)
+                    ,0x472   => array(0x473)
+                    ,0x474   => array(0x475)
+                    ,0x476   => array(0x477)
+                    ,0x478   => array(0x479)
+                    ,0x47A   => array(0x47B)
+                    ,0x47C   => array(0x47D)
+                    ,0x47E   => array(0x47F)
+                    ,0x480   => array(0x481)
+                    ,0x48A   => array(0x48B)
+                    ,0x48C   => array(0x48D)
+                    ,0x48E   => array(0x48F)
+                    ,0x490   => array(0x491)
+                    ,0x492   => array(0x493)
+                    ,0x494   => array(0x495)
+                    ,0x496   => array(0x497)
+                    ,0x498   => array(0x499)
+                    ,0x49A   => array(0x49B)
+                    ,0x49C   => array(0x49D)
+                    ,0x49E   => array(0x49F)
+                    ,0x4A0   => array(0x4A1)
+                    ,0x4A2   => array(0x4A3)
+                    ,0x4A4   => array(0x4A5)
+                    ,0x4A6   => array(0x4A7)
+                    ,0x4A8   => array(0x4A9)
+                    ,0x4AA   => array(0x4AB)
+                    ,0x4AC   => array(0x4AD)
+                    ,0x4AE   => array(0x4AF)
+                    ,0x4B0   => array(0x4B1)
+                    ,0x4B2   => array(0x4B3)
+                    ,0x4B4   => array(0x4B5)
+                    ,0x4B6   => array(0x4B7)
+                    ,0x4B8   => array(0x4B9)
+                    ,0x4BA   => array(0x4BB)
+                    ,0x4BC   => array(0x4BD)
+                    ,0x4BE   => array(0x4BF)
+                    ,0x4C1   => array(0x4C2)
+                    ,0x4C3   => array(0x4C4)
+                    ,0x4C5   => array(0x4C6)
+                    ,0x4C7   => array(0x4C8)
+                    ,0x4C9   => array(0x4CA)
+                    ,0x4CB   => array(0x4CC)
+                    ,0x4CD   => array(0x4CE)
+                    ,0x4D0   => array(0x4D1)
+                    ,0x4D2   => array(0x4D3)
+                    ,0x4D4   => array(0x4D5)
+                    ,0x4D6   => array(0x4D7)
+                    ,0x4D8   => array(0x4D9)
+                    ,0x4DA   => array(0x4DB)
+                    ,0x4DC   => array(0x4DD)
+                    ,0x4DE   => array(0x4DF)
+                    ,0x4E0   => array(0x4E1)
+                    ,0x4E2   => array(0x4E3)
+                    ,0x4E4   => array(0x4E5)
+                    ,0x4E6   => array(0x4E7)
+                    ,0x4E8   => array(0x4E9)
+                    ,0x4EA   => array(0x4EB)
+                    ,0x4EC   => array(0x4ED)
+                    ,0x4EE   => array(0x4EF)
+                    ,0x4F0   => array(0x4F1)
+                    ,0x4F2   => array(0x4F3)
+                    ,0x4F4   => array(0x4F5)
+                    ,0x4F8   => array(0x4F9)
+                    ,0x500   => array(0x501)
+                    ,0x502   => array(0x503)
+                    ,0x504   => array(0x505)
+                    ,0x506   => array(0x507)
+                    ,0x508   => array(0x509)
+                    ,0x50A   => array(0x50B)
+                    ,0x50C   => array(0x50D)
+                    ,0x50E   => array(0x50F)
+                    ,0x531   => array(0x561)
+                    ,0x532   => array(0x562)
+                    ,0x533   => array(0x563)
+                    ,0x534   => array(0x564)
+                    ,0x535   => array(0x565)
+                    ,0x536   => array(0x566)
+                    ,0x537   => array(0x567)
+                    ,0x538   => array(0x568)
+                    ,0x539   => array(0x569)
+                    ,0x53A   => array(0x56A)
+                    ,0x53B   => array(0x56B)
+                    ,0x53C   => array(0x56C)
+                    ,0x53D   => array(0x56D)
+                    ,0x53E   => array(0x56E)
+                    ,0x53F   => array(0x56F)
+                    ,0x540   => array(0x570)
+                    ,0x541   => array(0x571)
+                    ,0x542   => array(0x572)
+                    ,0x543   => array(0x573)
+                    ,0x544   => array(0x574)
+                    ,0x545   => array(0x575)
+                    ,0x546   => array(0x576)
+                    ,0x547   => array(0x577)
+                    ,0x548   => array(0x578)
+                    ,0x549   => array(0x579)
+                    ,0x54A   => array(0x57A)
+                    ,0x54B   => array(0x57B)
+                    ,0x54C   => array(0x57C)
+                    ,0x54D   => array(0x57D)
+                    ,0x54E   => array(0x57E)
+                    ,0x54F   => array(0x57F)
+                    ,0x550   => array(0x580)
+                    ,0x551   => array(0x581)
+                    ,0x552   => array(0x582)
+                    ,0x553   => array(0x583)
+                    ,0x554   => array(0x584)
+                    ,0x555   => array(0x585)
+                    ,0x556   => array(0x586)
+                    ,0x587   => array(0x565, 0x582)
+                    ,0x1E00  => array(0x1E01)
+                    ,0x1E02  => array(0x1E03)
+                    ,0x1E04  => array(0x1E05)
+                    ,0x1E06  => array(0x1E07)
+                    ,0x1E08  => array(0x1E09)
+                    ,0x1E0A  => array(0x1E0B)
+                    ,0x1E0C  => array(0x1E0D)
+                    ,0x1E0E  => array(0x1E0F)
+                    ,0x1E10  => array(0x1E11)
+                    ,0x1E12  => array(0x1E13)
+                    ,0x1E14  => array(0x1E15)
+                    ,0x1E16  => array(0x1E17)
+                    ,0x1E18  => array(0x1E19)
+                    ,0x1E1A  => array(0x1E1B)
+                    ,0x1E1C  => array(0x1E1D)
+                    ,0x1E1E  => array(0x1E1F)
+                    ,0x1E20  => array(0x1E21)
+                    ,0x1E22  => array(0x1E23)
+                    ,0x1E24  => array(0x1E25)
+                    ,0x1E26  => array(0x1E27)
+                    ,0x1E28  => array(0x1E29)
+                    ,0x1E2A  => array(0x1E2B)
+                    ,0x1E2C  => array(0x1E2D)
+                    ,0x1E2E  => array(0x1E2F)
+                    ,0x1E30  => array(0x1E31)
+                    ,0x1E32  => array(0x1E33)
+                    ,0x1E34  => array(0x1E35)
+                    ,0x1E36  => array(0x1E37)
+                    ,0x1E38  => array(0x1E39)
+                    ,0x1E3A  => array(0x1E3B)
+                    ,0x1E3C  => array(0x1E3D)
+                    ,0x1E3E  => array(0x1E3F)
+                    ,0x1E40  => array(0x1E41)
+                    ,0x1E42  => array(0x1E43)
+                    ,0x1E44  => array(0x1E45)
+                    ,0x1E46  => array(0x1E47)
+                    ,0x1E48  => array(0x1E49)
+                    ,0x1E4A  => array(0x1E4B)
+                    ,0x1E4C  => array(0x1E4D)
+                    ,0x1E4E  => array(0x1E4F)
+                    ,0x1E50  => array(0x1E51)
+                    ,0x1E52  => array(0x1E53)
+                    ,0x1E54  => array(0x1E55)
+                    ,0x1E56  => array(0x1E57)
+                    ,0x1E58  => array(0x1E59)
+                    ,0x1E5A  => array(0x1E5B)
+                    ,0x1E5C  => array(0x1E5D)
+                    ,0x1E5E  => array(0x1E5F)
+                    ,0x1E60  => array(0x1E61)
+                    ,0x1E62  => array(0x1E63)
+                    ,0x1E64  => array(0x1E65)
+                    ,0x1E66  => array(0x1E67)
+                    ,0x1E68  => array(0x1E69)
+                    ,0x1E6A  => array(0x1E6B)
+                    ,0x1E6C  => array(0x1E6D)
+                    ,0x1E6E  => array(0x1E6F)
+                    ,0x1E70  => array(0x1E71)
+                    ,0x1E72  => array(0x1E73)
+                    ,0x1E74  => array(0x1E75)
+                    ,0x1E76  => array(0x1E77)
+                    ,0x1E78  => array(0x1E79)
+                    ,0x1E7A  => array(0x1E7B)
+                    ,0x1E7C  => array(0x1E7D)
+                    ,0x1E7E  => array(0x1E7F)
+                    ,0x1E80  => array(0x1E81)
+                    ,0x1E82  => array(0x1E83)
+                    ,0x1E84  => array(0x1E85)
+                    ,0x1E86  => array(0x1E87)
+                    ,0x1E88  => array(0x1E89)
+                    ,0x1E8A  => array(0x1E8B)
+                    ,0x1E8C  => array(0x1E8D)
+                    ,0x1E8E  => array(0x1E8F)
+                    ,0x1E90  => array(0x1E91)
+                    ,0x1E92  => array(0x1E93)
+                    ,0x1E94  => array(0x1E95)
+                    ,0x1E96  => array(0x68, 0x331)
+                    ,0x1E97  => array(0x74, 0x308)
+                    ,0x1E98  => array(0x77, 0x30A)
+                    ,0x1E99  => array(0x79, 0x30A)
+                    ,0x1E9A  => array(0x61, 0x2BE)
+                    ,0x1E9B  => array(0x1E61)
+                    ,0x1EA0  => array(0x1EA1)
+                    ,0x1EA2  => array(0x1EA3)
+                    ,0x1EA4  => array(0x1EA5)
+                    ,0x1EA6  => array(0x1EA7)
+                    ,0x1EA8  => array(0x1EA9)
+                    ,0x1EAA  => array(0x1EAB)
+                    ,0x1EAC  => array(0x1EAD)
+                    ,0x1EAE  => array(0x1EAF)
+                    ,0x1EB0  => array(0x1EB1)
+                    ,0x1EB2  => array(0x1EB3)
+                    ,0x1EB4  => array(0x1EB5)
+                    ,0x1EB6  => array(0x1EB7)
+                    ,0x1EB8  => array(0x1EB9)
+                    ,0x1EBA  => array(0x1EBB)
+                    ,0x1EBC  => array(0x1EBD)
+                    ,0x1EBE  => array(0x1EBF)
+                    ,0x1EC0  => array(0x1EC1)
+                    ,0x1EC2  => array(0x1EC3)
+                    ,0x1EC4  => array(0x1EC5)
+                    ,0x1EC6  => array(0x1EC7)
+                    ,0x1EC8  => array(0x1EC9)
+                    ,0x1ECA  => array(0x1ECB)
+                    ,0x1ECC  => array(0x1ECD)
+                    ,0x1ECE  => array(0x1ECF)
+                    ,0x1ED0  => array(0x1ED1)
+                    ,0x1ED2  => array(0x1ED3)
+                    ,0x1ED4  => array(0x1ED5)
+                    ,0x1ED6  => array(0x1ED7)
+                    ,0x1ED8  => array(0x1ED9)
+                    ,0x1EDA  => array(0x1EDB)
+                    ,0x1EDC  => array(0x1EDD)
+                    ,0x1EDE  => array(0x1EDF)
+                    ,0x1EE0  => array(0x1EE1)
+                    ,0x1EE2  => array(0x1EE3)
+                    ,0x1EE4  => array(0x1EE5)
+                    ,0x1EE6  => array(0x1EE7)
+                    ,0x1EE8  => array(0x1EE9)
+                    ,0x1EEA  => array(0x1EEB)
+                    ,0x1EEC  => array(0x1EED)
+                    ,0x1EEE  => array(0x1EEF)
+                    ,0x1EF0  => array(0x1EF1)
+                    ,0x1EF2  => array(0x1EF3)
+                    ,0x1EF4  => array(0x1EF5)
+                    ,0x1EF6  => array(0x1EF7)
+                    ,0x1EF8  => array(0x1EF9)
+                    ,0x1F08  => array(0x1F00)
+                    ,0x1F09  => array(0x1F01)
+                    ,0x1F0A  => array(0x1F02)
+                    ,0x1F0B  => array(0x1F03)
+                    ,0x1F0C  => array(0x1F04)
+                    ,0x1F0D  => array(0x1F05)
+                    ,0x1F0E  => array(0x1F06)
+                    ,0x1F0F  => array(0x1F07)
+                    ,0x1F18  => array(0x1F10)
+                    ,0x1F19  => array(0x1F11)
+                    ,0x1F1A  => array(0x1F12)
+                    ,0x1F1B  => array(0x1F13)
+                    ,0x1F1C  => array(0x1F14)
+                    ,0x1F1D  => array(0x1F15)
+                    ,0x1F28  => array(0x1F20)
+                    ,0x1F29  => array(0x1F21)
+                    ,0x1F2A  => array(0x1F22)
+                    ,0x1F2B  => array(0x1F23)
+                    ,0x1F2C  => array(0x1F24)
+                    ,0x1F2D  => array(0x1F25)
+                    ,0x1F2E  => array(0x1F26)
+                    ,0x1F2F  => array(0x1F27)
+                    ,0x1F38  => array(0x1F30)
+                    ,0x1F39  => array(0x1F31)
+                    ,0x1F3A  => array(0x1F32)
+                    ,0x1F3B  => array(0x1F33)
+                    ,0x1F3C  => array(0x1F34)
+                    ,0x1F3D  => array(0x1F35)
+                    ,0x1F3E  => array(0x1F36)
+                    ,0x1F3F  => array(0x1F37)
+                    ,0x1F48  => array(0x1F40)
+                    ,0x1F49  => array(0x1F41)
+                    ,0x1F4A  => array(0x1F42)
+                    ,0x1F4B  => array(0x1F43)
+                    ,0x1F4C  => array(0x1F44)
+                    ,0x1F4D  => array(0x1F45)
+                    ,0x1F50  => array(0x3C5, 0x313)
+                    ,0x1F52  => array(0x3C5, 0x313, 0x300)
+                    ,0x1F54  => array(0x3C5, 0x313, 0x301)
+                    ,0x1F56  => array(0x3C5, 0x313, 0x342)
+                    ,0x1F59  => array(0x1F51)
+                    ,0x1F5B  => array(0x1F53)
+                    ,0x1F5D  => array(0x1F55)
+                    ,0x1F5F  => array(0x1F57)
+                    ,0x1F68  => array(0x1F60)
+                    ,0x1F69  => array(0x1F61)
+                    ,0x1F6A  => array(0x1F62)
+                    ,0x1F6B  => array(0x1F63)
+                    ,0x1F6C  => array(0x1F64)
+                    ,0x1F6D  => array(0x1F65)
+                    ,0x1F6E  => array(0x1F66)
+                    ,0x1F6F  => array(0x1F67)
+                    ,0x1F80  => array(0x1F00, 0x3B9)
+                    ,0x1F81  => array(0x1F01, 0x3B9)
+                    ,0x1F82  => array(0x1F02, 0x3B9)
+                    ,0x1F83  => array(0x1F03, 0x3B9)
+                    ,0x1F84  => array(0x1F04, 0x3B9)
+                    ,0x1F85  => array(0x1F05, 0x3B9)
+                    ,0x1F86  => array(0x1F06, 0x3B9)
+                    ,0x1F87  => array(0x1F07, 0x3B9)
+                    ,0x1F88  => array(0x1F00, 0x3B9)
+                    ,0x1F89  => array(0x1F01, 0x3B9)
+                    ,0x1F8A  => array(0x1F02, 0x3B9)
+                    ,0x1F8B  => array(0x1F03, 0x3B9)
+                    ,0x1F8C  => array(0x1F04, 0x3B9)
+                    ,0x1F8D  => array(0x1F05, 0x3B9)
+                    ,0x1F8E  => array(0x1F06, 0x3B9)
+                    ,0x1F8F  => array(0x1F07, 0x3B9)
+                    ,0x1F90  => array(0x1F20, 0x3B9)
+                    ,0x1F91  => array(0x1F21, 0x3B9)
+                    ,0x1F92  => array(0x1F22, 0x3B9)
+                    ,0x1F93  => array(0x1F23, 0x3B9)
+                    ,0x1F94  => array(0x1F24, 0x3B9)
+                    ,0x1F95  => array(0x1F25, 0x3B9)
+                    ,0x1F96  => array(0x1F26, 0x3B9)
+                    ,0x1F97  => array(0x1F27, 0x3B9)
+                    ,0x1F98  => array(0x1F20, 0x3B9)
+                    ,0x1F99  => array(0x1F21, 0x3B9)
+                    ,0x1F9A  => array(0x1F22, 0x3B9)
+                    ,0x1F9B  => array(0x1F23, 0x3B9)
+                    ,0x1F9C  => array(0x1F24, 0x3B9)
+                    ,0x1F9D  => array(0x1F25, 0x3B9)
+                    ,0x1F9E  => array(0x1F26, 0x3B9)
+                    ,0x1F9F  => array(0x1F27, 0x3B9)
+                    ,0x1FA0  => array(0x1F60, 0x3B9)
+                    ,0x1FA1  => array(0x1F61, 0x3B9)
+                    ,0x1FA2  => array(0x1F62, 0x3B9)
+                    ,0x1FA3  => array(0x1F63, 0x3B9)
+                    ,0x1FA4  => array(0x1F64, 0x3B9)
+                    ,0x1FA5  => array(0x1F65, 0x3B9)
+                    ,0x1FA6  => array(0x1F66, 0x3B9)
+                    ,0x1FA7  => array(0x1F67, 0x3B9)
+                    ,0x1FA8  => array(0x1F60, 0x3B9)
+                    ,0x1FA9  => array(0x1F61, 0x3B9)
+                    ,0x1FAA  => array(0x1F62, 0x3B9)
+                    ,0x1FAB  => array(0x1F63, 0x3B9)
+                    ,0x1FAC  => array(0x1F64, 0x3B9)
+                    ,0x1FAD  => array(0x1F65, 0x3B9)
+                    ,0x1FAE  => array(0x1F66, 0x3B9)
+                    ,0x1FAF  => array(0x1F67, 0x3B9)
+                    ,0x1FB2  => array(0x1F70, 0x3B9)
+                    ,0x1FB3  => array(0x3B1, 0x3B9)
+                    ,0x1FB4  => array(0x3AC, 0x3B9)
+                    ,0x1FB6  => array(0x3B1, 0x342)
+                    ,0x1FB7  => array(0x3B1, 0x342, 0x3B9)
+                    ,0x1FB8  => array(0x1FB0)
+                    ,0x1FB9  => array(0x1FB1)
+                    ,0x1FBA  => array(0x1F70)
+                    ,0x1FBB  => array(0x1F71)
+                    ,0x1FBC  => array(0x3B1, 0x3B9)
+                    ,0x1FBE  => array(0x3B9)
+                    ,0x1FC2  => array(0x1F74, 0x3B9)
+                    ,0x1FC3  => array(0x3B7, 0x3B9)
+                    ,0x1FC4  => array(0x3AE, 0x3B9)
+                    ,0x1FC6  => array(0x3B7, 0x342)
+                    ,0x1FC7  => array(0x3B7, 0x342, 0x3B9)
+                    ,0x1FC8  => array(0x1F72)
+                    ,0x1FC9  => array(0x1F73)
+                    ,0x1FCA  => array(0x1F74)
+                    ,0x1FCB  => array(0x1F75)
+                    ,0x1FCC  => array(0x3B7, 0x3B9)
+                    ,0x1FD2  => array(0x3B9, 0x308, 0x300)
+                    ,0x1FD3  => array(0x3B9, 0x308, 0x301)
+                    ,0x1FD6  => array(0x3B9, 0x342)
+                    ,0x1FD7  => array(0x3B9, 0x308, 0x342)
+                    ,0x1FD8  => array(0x1FD0)
+                    ,0x1FD9  => array(0x1FD1)
+                    ,0x1FDA  => array(0x1F76)
+                    ,0x1FDB  => array(0x1F77)
+                    ,0x1FE2  => array(0x3C5, 0x308, 0x300)
+                    ,0x1FE3  => array(0x3C5, 0x308, 0x301)
+                    ,0x1FE4  => array(0x3C1, 0x313)
+                    ,0x1FE6  => array(0x3C5, 0x342)
+                    ,0x1FE7  => array(0x3C5, 0x308, 0x342)
+                    ,0x1FE8  => array(0x1FE0)
+                    ,0x1FE9  => array(0x1FE1)
+                    ,0x1FEA  => array(0x1F7A)
+                    ,0x1FEB  => array(0x1F7B)
+                    ,0x1FEC  => array(0x1FE5)
+                    ,0x1FF2  => array(0x1F7C, 0x3B9)
+                    ,0x1FF3  => array(0x3C9, 0x3B9)
+                    ,0x1FF4  => array(0x3CE, 0x3B9)
+                    ,0x1FF6  => array(0x3C9, 0x342)
+                    ,0x1FF7  => array(0x3C9, 0x342, 0x3B9)
+                    ,0x1FF8  => array(0x1F78)
+                    ,0x1FF9  => array(0x1F79)
+                    ,0x1FFA  => array(0x1F7C)
+                    ,0x1FFB  => array(0x1F7D)
+                    ,0x1FFC  => array(0x3C9, 0x3B9)
+                    ,0x20A8  => array(0x72, 0x73)
+                    ,0x2102  => array(0x63)
+                    ,0x2103  => array(0xB0, 0x63)
+                    ,0x2107  => array(0x25B)
+                    ,0x2109  => array(0xB0, 0x66)
+                    ,0x210B  => array(0x68)
+                    ,0x210C  => array(0x68)
+                    ,0x210D  => array(0x68)
+                    ,0x2110  => array(0x69)
+                    ,0x2111  => array(0x69)
+                    ,0x2112  => array(0x6C)
+                    ,0x2115  => array(0x6E)
+                    ,0x2116  => array(0x6E, 0x6F)
+                    ,0x2119  => array(0x70)
+                    ,0x211A  => array(0x71)
+                    ,0x211B  => array(0x72)
+                    ,0x211C  => array(0x72)
+                    ,0x211D  => array(0x72)
+                    ,0x2120  => array(0x73, 0x6D)
+                    ,0x2121  => array(0x74, 0x65, 0x6C)
+                    ,0x2122  => array(0x74, 0x6D)
+                    ,0x2124  => array(0x7A)
+                    ,0x2126  => array(0x3C9)
+                    ,0x2128  => array(0x7A)
+                    ,0x212A  => array(0x6B)
+                    ,0x212B  => array(0xE5)
+                    ,0x212C  => array(0x62)
+                    ,0x212D  => array(0x63)
+                    ,0x2130  => array(0x65)
+                    ,0x2131  => array(0x66)
+                    ,0x2133  => array(0x6D)
+                    ,0x213E  => array(0x3B3)
+                    ,0x213F  => array(0x3C0)
+                    ,0x2145  => array(0x64)
+                    ,0x2160  => array(0x2170)
+                    ,0x2161  => array(0x2171)
+                    ,0x2162  => array(0x2172)
+                    ,0x2163  => array(0x2173)
+                    ,0x2164  => array(0x2174)
+                    ,0x2165  => array(0x2175)
+                    ,0x2166  => array(0x2176)
+                    ,0x2167  => array(0x2177)
+                    ,0x2168  => array(0x2178)
+                    ,0x2169  => array(0x2179)
+                    ,0x216A  => array(0x217A)
+                    ,0x216B  => array(0x217B)
+                    ,0x216C  => array(0x217C)
+                    ,0x216D  => array(0x217D)
+                    ,0x216E  => array(0x217E)
+                    ,0x216F  => array(0x217F)
+                    ,0x24B6  => array(0x24D0)
+                    ,0x24B7  => array(0x24D1)
+                    ,0x24B8  => array(0x24D2)
+                    ,0x24B9  => array(0x24D3)
+                    ,0x24BA  => array(0x24D4)
+                    ,0x24BB  => array(0x24D5)
+                    ,0x24BC  => array(0x24D6)
+                    ,0x24BD  => array(0x24D7)
+                    ,0x24BE  => array(0x24D8)
+                    ,0x24BF  => array(0x24D9)
+                    ,0x24C0  => array(0x24DA)
+                    ,0x24C1  => array(0x24DB)
+                    ,0x24C2  => array(0x24DC)
+                    ,0x24C3  => array(0x24DD)
+                    ,0x24C4  => array(0x24DE)
+                    ,0x24C5  => array(0x24DF)
+                    ,0x24C6  => array(0x24E0)
+                    ,0x24C7  => array(0x24E1)
+                    ,0x24C8  => array(0x24E2)
+                    ,0x24C9  => array(0x24E3)
+                    ,0x24CA  => array(0x24E4)
+                    ,0x24CB  => array(0x24E5)
+                    ,0x24CC  => array(0x24E6)
+                    ,0x24CD  => array(0x24E7)
+                    ,0x24CE  => array(0x24E8)
+                    ,0x24CF  => array(0x24E9)
+                    ,0x3371  => array(0x68, 0x70, 0x61)
+                    ,0x3373  => array(0x61, 0x75)
+                    ,0x3375  => array(0x6F, 0x76)
+                    ,0x3380  => array(0x70, 0x61)
+                    ,0x3381  => array(0x6E, 0x61)
+                    ,0x3382  => array(0x3BC, 0x61)
+                    ,0x3383  => array(0x6D, 0x61)
+                    ,0x3384  => array(0x6B, 0x61)
+                    ,0x3385  => array(0x6B, 0x62)
+                    ,0x3386  => array(0x6D, 0x62)
+                    ,0x3387  => array(0x67, 0x62)
+                    ,0x338A  => array(0x70, 0x66)
+                    ,0x338B  => array(0x6E, 0x66)
+                    ,0x338C  => array(0x3BC, 0x66)
+                    ,0x3390  => array(0x68, 0x7A)
+                    ,0x3391  => array(0x6B, 0x68, 0x7A)
+                    ,0x3392  => array(0x6D, 0x68, 0x7A)
+                    ,0x3393  => array(0x67, 0x68, 0x7A)
+                    ,0x3394  => array(0x74, 0x68, 0x7A)
+                    ,0x33A9  => array(0x70, 0x61)
+                    ,0x33AA  => array(0x6B, 0x70, 0x61)
+                    ,0x33AB  => array(0x6D, 0x70, 0x61)
+                    ,0x33AC  => array(0x67, 0x70, 0x61)
+                    ,0x33B4  => array(0x70, 0x76)
+                    ,0x33B5  => array(0x6E, 0x76)
+                    ,0x33B6  => array(0x3BC, 0x76)
+                    ,0x33B7  => array(0x6D, 0x76)
+                    ,0x33B8  => array(0x6B, 0x76)
+                    ,0x33B9  => array(0x6D, 0x76)
+                    ,0x33BA  => array(0x70, 0x77)
+                    ,0x33BB  => array(0x6E, 0x77)
+                    ,0x33BC  => array(0x3BC, 0x77)
+                    ,0x33BD  => array(0x6D, 0x77)
+                    ,0x33BE  => array(0x6B, 0x77)
+                    ,0x33BF  => array(0x6D, 0x77)
+                    ,0x33C0  => array(0x6B, 0x3C9)
+                    ,0x33C1  => array(0x6D, 0x3C9) /*
+                    ,0x33C2  => array(0x61, 0x2E, 0x6D, 0x2E) */
+                    ,0x33C3  => array(0x62, 0x71)
+                    ,0x33C6  => array(0x63, 0x2215, 0x6B, 0x67)
+                    ,0x33C7  => array(0x63, 0x6F, 0x2E)
+                    ,0x33C8  => array(0x64, 0x62)
+                    ,0x33C9  => array(0x67, 0x79)
+                    ,0x33CB  => array(0x68, 0x70)
+                    ,0x33CD  => array(0x6B, 0x6B)
+                    ,0x33CE  => array(0x6B, 0x6D)
+                    ,0x33D7  => array(0x70, 0x68)
+                    ,0x33D9  => array(0x70, 0x70, 0x6D)
+                    ,0x33DA  => array(0x70, 0x72)
+                    ,0x33DC  => array(0x73, 0x76)
+                    ,0x33DD  => array(0x77, 0x62)
+                    ,0xFB00  => array(0x66, 0x66)
+                    ,0xFB01  => array(0x66, 0x69)
+                    ,0xFB02  => array(0x66, 0x6C)
+                    ,0xFB03  => array(0x66, 0x66, 0x69)
+                    ,0xFB04  => array(0x66, 0x66, 0x6C)
+                    ,0xFB05  => array(0x73, 0x74)
+                    ,0xFB06  => array(0x73, 0x74)
+                    ,0xFB13  => array(0x574, 0x576)
+                    ,0xFB14  => array(0x574, 0x565)
+                    ,0xFB15  => array(0x574, 0x56B)
+                    ,0xFB16  => array(0x57E, 0x576)
+                    ,0xFB17  => array(0x574, 0x56D)
+                    ,0xFF21  => array(0xFF41)
+                    ,0xFF22  => array(0xFF42)
+                    ,0xFF23  => array(0xFF43)
+                    ,0xFF24  => array(0xFF44)
+                    ,0xFF25  => array(0xFF45)
+                    ,0xFF26  => array(0xFF46)
+                    ,0xFF27  => array(0xFF47)
+                    ,0xFF28  => array(0xFF48)
+                    ,0xFF29  => array(0xFF49)
+                    ,0xFF2A  => array(0xFF4A)
+                    ,0xFF2B  => array(0xFF4B)
+                    ,0xFF2C  => array(0xFF4C)
+                    ,0xFF2D  => array(0xFF4D)
+                    ,0xFF2E  => array(0xFF4E)
+                    ,0xFF2F  => array(0xFF4F)
+                    ,0xFF30  => array(0xFF50)
+                    ,0xFF31  => array(0xFF51)
+                    ,0xFF32  => array(0xFF52)
+                    ,0xFF33  => array(0xFF53)
+                    ,0xFF34  => array(0xFF54)
+                    ,0xFF35  => array(0xFF55)
+                    ,0xFF36  => array(0xFF56)
+                    ,0xFF37  => array(0xFF57)
+                    ,0xFF38  => array(0xFF58)
+                    ,0xFF39  => array(0xFF59)
+                    ,0xFF3A  => array(0xFF5A)
+                    ,0x10400 => array(0x10428)
+                    ,0x10401 => array(0x10429)
+                    ,0x10402 => array(0x1042A)
+                    ,0x10403 => array(0x1042B)
+                    ,0x10404 => array(0x1042C)
+                    ,0x10405 => array(0x1042D)
+                    ,0x10406 => array(0x1042E)
+                    ,0x10407 => array(0x1042F)
+                    ,0x10408 => array(0x10430)
+                    ,0x10409 => array(0x10431)
+                    ,0x1040A => array(0x10432)
+                    ,0x1040B => array(0x10433)
+                    ,0x1040C => array(0x10434)
+                    ,0x1040D => array(0x10435)
+                    ,0x1040E => array(0x10436)
+                    ,0x1040F => array(0x10437)
+                    ,0x10410 => array(0x10438)
+                    ,0x10411 => array(0x10439)
+                    ,0x10412 => array(0x1043A)
+                    ,0x10413 => array(0x1043B)
+                    ,0x10414 => array(0x1043C)
+                    ,0x10415 => array(0x1043D)
+                    ,0x10416 => array(0x1043E)
+                    ,0x10417 => array(0x1043F)
+                    ,0x10418 => array(0x10440)
+                    ,0x10419 => array(0x10441)
+                    ,0x1041A => array(0x10442)
+                    ,0x1041B => array(0x10443)
+                    ,0x1041C => array(0x10444)
+                    ,0x1041D => array(0x10445)
+                    ,0x1041E => array(0x10446)
+                    ,0x1041F => array(0x10447)
+                    ,0x10420 => array(0x10448)
+                    ,0x10421 => array(0x10449)
+                    ,0x10422 => array(0x1044A)
+                    ,0x10423 => array(0x1044B)
+                    ,0x10424 => array(0x1044C)
+                    ,0x10425 => array(0x1044D)
+                    ,0x1D400 => array(0x61)
+                    ,0x1D401 => array(0x62)
+                    ,0x1D402 => array(0x63)
+                    ,0x1D403 => array(0x64)
+                    ,0x1D404 => array(0x65)
+                    ,0x1D405 => array(0x66)
+                    ,0x1D406 => array(0x67)
+                    ,0x1D407 => array(0x68)
+                    ,0x1D408 => array(0x69)
+                    ,0x1D409 => array(0x6A)
+                    ,0x1D40A => array(0x6B)
+                    ,0x1D40B => array(0x6C)
+                    ,0x1D40C => array(0x6D)
+                    ,0x1D40D => array(0x6E)
+                    ,0x1D40E => array(0x6F)
+                    ,0x1D40F => array(0x70)
+                    ,0x1D410 => array(0x71)
+                    ,0x1D411 => array(0x72)
+                    ,0x1D412 => array(0x73)
+                    ,0x1D413 => array(0x74)
+                    ,0x1D414 => array(0x75)
+                    ,0x1D415 => array(0x76)
+                    ,0x1D416 => array(0x77)
+                    ,0x1D417 => array(0x78)
+                    ,0x1D418 => array(0x79)
+                    ,0x1D419 => array(0x7A)
+                    ,0x1D434 => array(0x61)
+                    ,0x1D435 => array(0x62)
+                    ,0x1D436 => array(0x63)
+                    ,0x1D437 => array(0x64)
+                    ,0x1D438 => array(0x65)
+                    ,0x1D439 => array(0x66)
+                    ,0x1D43A => array(0x67)
+                    ,0x1D43B => array(0x68)
+                    ,0x1D43C => array(0x69)
+                    ,0x1D43D => array(0x6A)
+                    ,0x1D43E => array(0x6B)
+                    ,0x1D43F => array(0x6C)
+                    ,0x1D440 => array(0x6D)
+                    ,0x1D441 => array(0x6E)
+                    ,0x1D442 => array(0x6F)
+                    ,0x1D443 => array(0x70)
+                    ,0x1D444 => array(0x71)
+                    ,0x1D445 => array(0x72)
+                    ,0x1D446 => array(0x73)
+                    ,0x1D447 => array(0x74)
+                    ,0x1D448 => array(0x75)
+                    ,0x1D449 => array(0x76)
+                    ,0x1D44A => array(0x77)
+                    ,0x1D44B => array(0x78)
+                    ,0x1D44C => array(0x79)
+                    ,0x1D44D => array(0x7A)
+                    ,0x1D468 => array(0x61)
+                    ,0x1D469 => array(0x62)
+                    ,0x1D46A => array(0x63)
+                    ,0x1D46B => array(0x64)
+                    ,0x1D46C => array(0x65)
+                    ,0x1D46D => array(0x66)
+                    ,0x1D46E => array(0x67)
+                    ,0x1D46F => array(0x68)
+                    ,0x1D470 => array(0x69)
+                    ,0x1D471 => array(0x6A)
+                    ,0x1D472 => array(0x6B)
+                    ,0x1D473 => array(0x6C)
+                    ,0x1D474 => array(0x6D)
+                    ,0x1D475 => array(0x6E)
+                    ,0x1D476 => array(0x6F)
+                    ,0x1D477 => array(0x70)
+                    ,0x1D478 => array(0x71)
+                    ,0x1D479 => array(0x72)
+                    ,0x1D47A => array(0x73)
+                    ,0x1D47B => array(0x74)
+                    ,0x1D47C => array(0x75)
+                    ,0x1D47D => array(0x76)
+                    ,0x1D47E => array(0x77)
+                    ,0x1D47F => array(0x78)
+                    ,0x1D480 => array(0x79)
+                    ,0x1D481 => array(0x7A)
+                    ,0x1D49C => array(0x61)
+                    ,0x1D49E => array(0x63)
+                    ,0x1D49F => array(0x64)
+                    ,0x1D4A2 => array(0x67)
+                    ,0x1D4A5 => array(0x6A)
+                    ,0x1D4A6 => array(0x6B)
+                    ,0x1D4A9 => array(0x6E)
+                    ,0x1D4AA => array(0x6F)
+                    ,0x1D4AB => array(0x70)
+                    ,0x1D4AC => array(0x71)
+                    ,0x1D4AE => array(0x73)
+                    ,0x1D4AF => array(0x74)
+                    ,0x1D4B0 => array(0x75)
+                    ,0x1D4B1 => array(0x76)
+                    ,0x1D4B2 => array(0x77)
+                    ,0x1D4B3 => array(0x78)
+                    ,0x1D4B4 => array(0x79)
+                    ,0x1D4B5 => array(0x7A)
+                    ,0x1D4D0 => array(0x61)
+                    ,0x1D4D1 => array(0x62)
+                    ,0x1D4D2 => array(0x63)
+                    ,0x1D4D3 => array(0x64)
+                    ,0x1D4D4 => array(0x65)
+                    ,0x1D4D5 => array(0x66)
+                    ,0x1D4D6 => array(0x67)
+                    ,0x1D4D7 => array(0x68)
+                    ,0x1D4D8 => array(0x69)
+                    ,0x1D4D9 => array(0x6A)
+                    ,0x1D4DA => array(0x6B)
+                    ,0x1D4DB => array(0x6C)
+                    ,0x1D4DC => array(0x6D)
+                    ,0x1D4DD => array(0x6E)
+                    ,0x1D4DE => array(0x6F)
+                    ,0x1D4DF => array(0x70)
+                    ,0x1D4E0 => array(0x71)
+                    ,0x1D4E1 => array(0x72)
+                    ,0x1D4E2 => array(0x73)
+                    ,0x1D4E3 => array(0x74)
+                    ,0x1D4E4 => array(0x75)
+                    ,0x1D4E5 => array(0x76)
+                    ,0x1D4E6 => array(0x77)
+                    ,0x1D4E7 => array(0x78)
+                    ,0x1D4E8 => array(0x79)
+                    ,0x1D4E9 => array(0x7A)
+                    ,0x1D504 => array(0x61)
+                    ,0x1D505 => array(0x62)
+                    ,0x1D507 => array(0x64)
+                    ,0x1D508 => array(0x65)
+                    ,0x1D509 => array(0x66)
+                    ,0x1D50A => array(0x67)
+                    ,0x1D50D => array(0x6A)
+                    ,0x1D50E => array(0x6B)
+                    ,0x1D50F => array(0x6C)
+                    ,0x1D510 => array(0x6D)
+                    ,0x1D511 => array(0x6E)
+                    ,0x1D512 => array(0x6F)
+                    ,0x1D513 => array(0x70)
+                    ,0x1D514 => array(0x71)
+                    ,0x1D516 => array(0x73)
+                    ,0x1D517 => array(0x74)
+                    ,0x1D518 => array(0x75)
+                    ,0x1D519 => array(0x76)
+                    ,0x1D51A => array(0x77)
+                    ,0x1D51B => array(0x78)
+                    ,0x1D51C => array(0x79)
+                    ,0x1D538 => array(0x61)
+                    ,0x1D539 => array(0x62)
+                    ,0x1D53B => array(0x64)
+                    ,0x1D53C => array(0x65)
+                    ,0x1D53D => array(0x66)
+                    ,0x1D53E => array(0x67)
+                    ,0x1D540 => array(0x69)
+                    ,0x1D541 => array(0x6A)
+                    ,0x1D542 => array(0x6B)
+                    ,0x1D543 => array(0x6C)
+                    ,0x1D544 => array(0x6D)
+                    ,0x1D546 => array(0x6F)
+                    ,0x1D54A => array(0x73)
+                    ,0x1D54B => array(0x74)
+                    ,0x1D54C => array(0x75)
+                    ,0x1D54D => array(0x76)
+                    ,0x1D54E => array(0x77)
+                    ,0x1D54F => array(0x78)
+                    ,0x1D550 => array(0x79)
+                    ,0x1D56C => array(0x61)
+                    ,0x1D56D => array(0x62)
+                    ,0x1D56E => array(0x63)
+                    ,0x1D56F => array(0x64)
+                    ,0x1D570 => array(0x65)
+                    ,0x1D571 => array(0x66)
+                    ,0x1D572 => array(0x67)
+                    ,0x1D573 => array(0x68)
+                    ,0x1D574 => array(0x69)
+                    ,0x1D575 => array(0x6A)
+                    ,0x1D576 => array(0x6B)
+                    ,0x1D577 => array(0x6C)
+                    ,0x1D578 => array(0x6D)
+                    ,0x1D579 => array(0x6E)
+                    ,0x1D57A => array(0x6F)
+                    ,0x1D57B => array(0x70)
+                    ,0x1D57C => array(0x71)
+                    ,0x1D57D => array(0x72)
+                    ,0x1D57E => array(0x73)
+                    ,0x1D57F => array(0x74)
+                    ,0x1D580 => array(0x75)
+                    ,0x1D581 => array(0x76)
+                    ,0x1D582 => array(0x77)
+                    ,0x1D583 => array(0x78)
+                    ,0x1D584 => array(0x79)
+                    ,0x1D585 => array(0x7A)
+                    ,0x1D5A0 => array(0x61)
+                    ,0x1D5A1 => array(0x62)
+                    ,0x1D5A2 => array(0x63)
+                    ,0x1D5A3 => array(0x64)
+                    ,0x1D5A4 => array(0x65)
+                    ,0x1D5A5 => array(0x66)
+                    ,0x1D5A6 => array(0x67)
+                    ,0x1D5A7 => array(0x68)
+                    ,0x1D5A8 => array(0x69)
+                    ,0x1D5A9 => array(0x6A)
+                    ,0x1D5AA => array(0x6B)
+                    ,0x1D5AB => array(0x6C)
+                    ,0x1D5AC => array(0x6D)
+                    ,0x1D5AD => array(0x6E)
+                    ,0x1D5AE => array(0x6F)
+                    ,0x1D5AF => array(0x70)
+                    ,0x1D5B0 => array(0x71)
+                    ,0x1D5B1 => array(0x72)
+                    ,0x1D5B2 => array(0x73)
+                    ,0x1D5B3 => array(0x74)
+                    ,0x1D5B4 => array(0x75)
+                    ,0x1D5B5 => array(0x76)
+                    ,0x1D5B6 => array(0x77)
+                    ,0x1D5B7 => array(0x78)
+                    ,0x1D5B8 => array(0x79)
+                    ,0x1D5B9 => array(0x7A)
+                    ,0x1D5D4 => array(0x61)
+                    ,0x1D5D5 => array(0x62)
+                    ,0x1D5D6 => array(0x63)
+                    ,0x1D5D7 => array(0x64)
+                    ,0x1D5D8 => array(0x65)
+                    ,0x1D5D9 => array(0x66)
+                    ,0x1D5DA => array(0x67)
+                    ,0x1D5DB => array(0x68)
+                    ,0x1D5DC => array(0x69)
+                    ,0x1D5DD => array(0x6A)
+                    ,0x1D5DE => array(0x6B)
+                    ,0x1D5DF => array(0x6C)
+                    ,0x1D5E0 => array(0x6D)
+                    ,0x1D5E1 => array(0x6E)
+                    ,0x1D5E2 => array(0x6F)
+                    ,0x1D5E3 => array(0x70)
+                    ,0x1D5E4 => array(0x71)
+                    ,0x1D5E5 => array(0x72)
+                    ,0x1D5E6 => array(0x73)
+                    ,0x1D5E7 => array(0x74)
+                    ,0x1D5E8 => array(0x75)
+                    ,0x1D5E9 => array(0x76)
+                    ,0x1D5EA => array(0x77)
+                    ,0x1D5EB => array(0x78)
+                    ,0x1D5EC => array(0x79)
+                    ,0x1D5ED => array(0x7A)
+                    ,0x1D608 => array(0x61)
+                    ,0x1D609 => array(0x62)
+                    ,0x1D60A => array(0x63)
+                    ,0x1D60B => array(0x64)
+                    ,0x1D60C => array(0x65)
+                    ,0x1D60D => array(0x66)
+                    ,0x1D60E => array(0x67)
+                    ,0x1D60F => array(0x68)
+                    ,0x1D610 => array(0x69)
+                    ,0x1D611 => array(0x6A)
+                    ,0x1D612 => array(0x6B)
+                    ,0x1D613 => array(0x6C)
+                    ,0x1D614 => array(0x6D)
+                    ,0x1D615 => array(0x6E)
+                    ,0x1D616 => array(0x6F)
+                    ,0x1D617 => array(0x70)
+                    ,0x1D618 => array(0x71)
+                    ,0x1D619 => array(0x72)
+                    ,0x1D61A => array(0x73)
+                    ,0x1D61B => array(0x74)
+                    ,0x1D61C => array(0x75)
+                    ,0x1D61D => array(0x76)
+                    ,0x1D61E => array(0x77)
+                    ,0x1D61F => array(0x78)
+                    ,0x1D620 => array(0x79)
+                    ,0x1D621 => array(0x7A)
+                    ,0x1D63C => array(0x61)
+                    ,0x1D63D => array(0x62)
+                    ,0x1D63E => array(0x63)
+                    ,0x1D63F => array(0x64)
+                    ,0x1D640 => array(0x65)
+                    ,0x1D641 => array(0x66)
+                    ,0x1D642 => array(0x67)
+                    ,0x1D643 => array(0x68)
+                    ,0x1D644 => array(0x69)
+                    ,0x1D645 => array(0x6A)
+                    ,0x1D646 => array(0x6B)
+                    ,0x1D647 => array(0x6C)
+                    ,0x1D648 => array(0x6D)
+                    ,0x1D649 => array(0x6E)
+                    ,0x1D64A => array(0x6F)
+                    ,0x1D64B => array(0x70)
+                    ,0x1D64C => array(0x71)
+                    ,0x1D64D => array(0x72)
+                    ,0x1D64E => array(0x73)
+                    ,0x1D64F => array(0x74)
+                    ,0x1D650 => array(0x75)
+                    ,0x1D651 => array(0x76)
+                    ,0x1D652 => array(0x77)
+                    ,0x1D653 => array(0x78)
+                    ,0x1D654 => array(0x79)
+                    ,0x1D655 => array(0x7A)
+                    ,0x1D670 => array(0x61)
+                    ,0x1D671 => array(0x62)
+                    ,0x1D672 => array(0x63)
+                    ,0x1D673 => array(0x64)
+                    ,0x1D674 => array(0x65)
+                    ,0x1D675 => array(0x66)
+                    ,0x1D676 => array(0x67)
+                    ,0x1D677 => array(0x68)
+                    ,0x1D678 => array(0x69)
+                    ,0x1D679 => array(0x6A)
+                    ,0x1D67A => array(0x6B)
+                    ,0x1D67B => array(0x6C)
+                    ,0x1D67C => array(0x6D)
+                    ,0x1D67D => array(0x6E)
+                    ,0x1D67E => array(0x6F)
+                    ,0x1D67F => array(0x70)
+                    ,0x1D680 => array(0x71)
+                    ,0x1D681 => array(0x72)
+                    ,0x1D682 => array(0x73)
+                    ,0x1D683 => array(0x74)
+                    ,0x1D684 => array(0x75)
+                    ,0x1D685 => array(0x76)
+                    ,0x1D686 => array(0x77)
+                    ,0x1D687 => array(0x78)
+                    ,0x1D688 => array(0x79)
+                    ,0x1D689 => array(0x7A)
+                    ,0x1D6A8 => array(0x3B1)
+                    ,0x1D6A9 => array(0x3B2)
+                    ,0x1D6AA => array(0x3B3)
+                    ,0x1D6AB => array(0x3B4)
+                    ,0x1D6AC => array(0x3B5)
+                    ,0x1D6AD => array(0x3B6)
+                    ,0x1D6AE => array(0x3B7)
+                    ,0x1D6AF => array(0x3B8)
+                    ,0x1D6B0 => array(0x3B9)
+                    ,0x1D6B1 => array(0x3BA)
+                    ,0x1D6B2 => array(0x3BB)
+                    ,0x1D6B3 => array(0x3BC)
+                    ,0x1D6B4 => array(0x3BD)
+                    ,0x1D6B5 => array(0x3BE)
+                    ,0x1D6B6 => array(0x3BF)
+                    ,0x1D6B7 => array(0x3C0)
+                    ,0x1D6B8 => array(0x3C1)
+                    ,0x1D6B9 => array(0x3B8)
+                    ,0x1D6BA => array(0x3C3)
+                    ,0x1D6BB => array(0x3C4)
+                    ,0x1D6BC => array(0x3C5)
+                    ,0x1D6BD => array(0x3C6)
+                    ,0x1D6BE => array(0x3C7)
+                    ,0x1D6BF => array(0x3C8)
+                    ,0x1D6C0 => array(0x3C9)
+                    ,0x1D6D3 => array(0x3C3)
+                    ,0x1D6E2 => array(0x3B1)
+                    ,0x1D6E3 => array(0x3B2)
+                    ,0x1D6E4 => array(0x3B3)
+                    ,0x1D6E5 => array(0x3B4)
+                    ,0x1D6E6 => array(0x3B5)
+                    ,0x1D6E7 => array(0x3B6)
+                    ,0x1D6E8 => array(0x3B7)
+                    ,0x1D6E9 => array(0x3B8)
+                    ,0x1D6EA => array(0x3B9)
+                    ,0x1D6EB => array(0x3BA)
+                    ,0x1D6EC => array(0x3BB)
+                    ,0x1D6ED => array(0x3BC)
+                    ,0x1D6EE => array(0x3BD)
+                    ,0x1D6EF => array(0x3BE)
+                    ,0x1D6F0 => array(0x3BF)
+                    ,0x1D6F1 => array(0x3C0)
+                    ,0x1D6F2 => array(0x3C1)
+                    ,0x1D6F3 => array(0x3B8)
+                    ,0x1D6F4 => array(0x3C3)
+                    ,0x1D6F5 => array(0x3C4)
+                    ,0x1D6F6 => array(0x3C5)
+                    ,0x1D6F7 => array(0x3C6)
+                    ,0x1D6F8 => array(0x3C7)
+                    ,0x1D6F9 => array(0x3C8)
+                    ,0x1D6FA => array(0x3C9)
+                    ,0x1D70D => array(0x3C3)
+                    ,0x1D71C => array(0x3B1)
+                    ,0x1D71D => array(0x3B2)
+                    ,0x1D71E => array(0x3B3)
+                    ,0x1D71F => array(0x3B4)
+                    ,0x1D720 => array(0x3B5)
+                    ,0x1D721 => array(0x3B6)
+                    ,0x1D722 => array(0x3B7)
+                    ,0x1D723 => array(0x3B8)
+                    ,0x1D724 => array(0x3B9)
+                    ,0x1D725 => array(0x3BA)
+                    ,0x1D726 => array(0x3BB)
+                    ,0x1D727 => array(0x3BC)
+                    ,0x1D728 => array(0x3BD)
+                    ,0x1D729 => array(0x3BE)
+                    ,0x1D72A => array(0x3BF)
+                    ,0x1D72B => array(0x3C0)
+                    ,0x1D72C => array(0x3C1)
+                    ,0x1D72D => array(0x3B8)
+                    ,0x1D72E => array(0x3C3)
+                    ,0x1D72F => array(0x3C4)
+                    ,0x1D730 => array(0x3C5)
+                    ,0x1D731 => array(0x3C6)
+                    ,0x1D732 => array(0x3C7)
+                    ,0x1D733 => array(0x3C8)
+                    ,0x1D734 => array(0x3C9)
+                    ,0x1D747 => array(0x3C3)
+                    ,0x1D756 => array(0x3B1)
+                    ,0x1D757 => array(0x3B2)
+                    ,0x1D758 => array(0x3B3)
+                    ,0x1D759 => array(0x3B4)
+                    ,0x1D75A => array(0x3B5)
+                    ,0x1D75B => array(0x3B6)
+                    ,0x1D75C => array(0x3B7)
+                    ,0x1D75D => array(0x3B8)
+                    ,0x1D75E => array(0x3B9)
+                    ,0x1D75F => array(0x3BA)
+                    ,0x1D760 => array(0x3BB)
+                    ,0x1D761 => array(0x3BC)
+                    ,0x1D762 => array(0x3BD)
+                    ,0x1D763 => array(0x3BE)
+                    ,0x1D764 => array(0x3BF)
+                    ,0x1D765 => array(0x3C0)
+                    ,0x1D766 => array(0x3C1)
+                    ,0x1D767 => array(0x3B8)
+                    ,0x1D768 => array(0x3C3)
+                    ,0x1D769 => array(0x3C4)
+                    ,0x1D76A => array(0x3C5)
+                    ,0x1D76B => array(0x3C6)
+                    ,0x1D76C => array(0x3C7)
+                    ,0x1D76D => array(0x3C8)
+                    ,0x1D76E => array(0x3C9)
+                    ,0x1D781 => array(0x3C3)
+                    ,0x1D790 => array(0x3B1)
+                    ,0x1D791 => array(0x3B2)
+                    ,0x1D792 => array(0x3B3)
+                    ,0x1D793 => array(0x3B4)
+                    ,0x1D794 => array(0x3B5)
+                    ,0x1D795 => array(0x3B6)
+                    ,0x1D796 => array(0x3B7)
+                    ,0x1D797 => array(0x3B8)
+                    ,0x1D798 => array(0x3B9)
+                    ,0x1D799 => array(0x3BA)
+                    ,0x1D79A => array(0x3BB)
+                    ,0x1D79B => array(0x3BC)
+                    ,0x1D79C => array(0x3BD)
+                    ,0x1D79D => array(0x3BE)
+                    ,0x1D79E => array(0x3BF)
+                    ,0x1D79F => array(0x3C0)
+                    ,0x1D7A0 => array(0x3C1)
+                    ,0x1D7A1 => array(0x3B8)
+                    ,0x1D7A2 => array(0x3C3)
+                    ,0x1D7A3 => array(0x3C4)
+                    ,0x1D7A4 => array(0x3C5)
+                    ,0x1D7A5 => array(0x3C6)
+                    ,0x1D7A6 => array(0x3C7)
+                    ,0x1D7A7 => array(0x3C8)
+                    ,0x1D7A8 => array(0x3C9)
+                    ,0x1D7BB => array(0x3C3)
+                    ,0x3F9   => array(0x3C3)
+                    ,0x1D2C  => array(0x61)
+                    ,0x1D2D  => array(0xE6)
+                    ,0x1D2E  => array(0x62)
+                    ,0x1D30  => array(0x64)
+                    ,0x1D31  => array(0x65)
+                    ,0x1D32  => array(0x1DD)
+                    ,0x1D33  => array(0x67)
+                    ,0x1D34  => array(0x68)
+                    ,0x1D35  => array(0x69)
+                    ,0x1D36  => array(0x6A)
+                    ,0x1D37  => array(0x6B)
+                    ,0x1D38  => array(0x6C)
+                    ,0x1D39  => array(0x6D)
+                    ,0x1D3A  => array(0x6E)
+                    ,0x1D3C  => array(0x6F)
+                    ,0x1D3D  => array(0x223)
+                    ,0x1D3E  => array(0x70)
+                    ,0x1D3F  => array(0x72)
+                    ,0x1D40  => array(0x74)
+                    ,0x1D41  => array(0x75)
+                    ,0x1D42  => array(0x77)
+                    ,0x213B  => array(0x66, 0x61, 0x78)
+                    ,0x3250  => array(0x70, 0x74, 0x65)
+                    ,0x32CC  => array(0x68, 0x67)
+                    ,0x32CE  => array(0x65, 0x76)
+                    ,0x32CF  => array(0x6C, 0x74, 0x64)
+                    ,0x337A  => array(0x69, 0x75)
+                    ,0x33DE  => array(0x76, 0x2215, 0x6D)
+                    ,0x33DF  => array(0x61, 0x2215, 0x6D)
+                    )
+            ,'norm_combcls' => array
+                    (0x334   => 1
+                    ,0x335   => 1
+                    ,0x336   => 1
+                    ,0x337   => 1
+                    ,0x338   => 1
+                    ,0x93C   => 7
+                    ,0x9BC   => 7
+                    ,0xA3C   => 7
+                    ,0xABC   => 7
+                    ,0xB3C   => 7
+                    ,0xCBC   => 7
+                    ,0x1037  => 7
+                    ,0x3099  => 8
+                    ,0x309A  => 8
+                    ,0x94D   => 9
+                    ,0x9CD   => 9
+                    ,0xA4D   => 9
+                    ,0xACD   => 9
+                    ,0xB4D   => 9
+                    ,0xBCD   => 9
+                    ,0xC4D   => 9
+                    ,0xCCD   => 9
+                    ,0xD4D   => 9
+                    ,0xDCA   => 9
+                    ,0xE3A   => 9
+                    ,0xF84   => 9
+                    ,0x1039  => 9
+                    ,0x1714  => 9
+                    ,0x1734  => 9
+                    ,0x17D2  => 9
+                    ,0x5B0   => 10
+                    ,0x5B1   => 11
+                    ,0x5B2   => 12
+                    ,0x5B3   => 13
+                    ,0x5B4   => 14
+                    ,0x5B5   => 15
+                    ,0x5B6   => 16
+                    ,0x5B7   => 17
+                    ,0x5B8   => 18
+                    ,0x5B9   => 19
+                    ,0x5BB   => 20
+                    ,0x5Bc   => 21
+                    ,0x5BD   => 22
+                    ,0x5BF   => 23
+                    ,0x5C1   => 24
+                    ,0x5C2   => 25
+                    ,0xFB1E  => 26
+                    ,0x64B   => 27
+                    ,0x64C   => 28
+                    ,0x64D   => 29
+                    ,0x64E   => 30
+                    ,0x64F   => 31
+                    ,0x650   => 32
+                    ,0x651   => 33
+                    ,0x652   => 34
+                    ,0x670   => 35
+                    ,0x711   => 36
+                    ,0xC55   => 84
+                    ,0xC56   => 91
+                    ,0xE38   => 103
+                    ,0xE39   => 103
+                    ,0xE48   => 107
+                    ,0xE49   => 107
+                    ,0xE4A   => 107
+                    ,0xE4B   => 107
+                    ,0xEB8   => 118
+                    ,0xEB9   => 118
+                    ,0xEC8   => 122
+                    ,0xEC9   => 122
+                    ,0xECA   => 122
+                    ,0xECB   => 122
+                    ,0xF71   => 129
+                    ,0xF72   => 130
+                    ,0xF7A   => 130
+                    ,0xF7B   => 130
+                    ,0xF7C   => 130
+                    ,0xF7D   => 130
+                    ,0xF80   => 130
+                    ,0xF74   => 132
+                    ,0x321   => 202
+                    ,0x322   => 202
+                    ,0x327   => 202
+                    ,0x328   => 202
+                    ,0x31B   => 216
+                    ,0xF39   => 216
+                    ,0x1D165 => 216
+                    ,0x1D166 => 216
+                    ,0x1D16E => 216
+                    ,0x1D16F => 216
+                    ,0x1D170 => 216
+                    ,0x1D171 => 216
+                    ,0x1D172 => 216
+                    ,0x302A  => 218
+                    ,0x316   => 220
+                    ,0x317   => 220
+                    ,0x318   => 220
+                    ,0x319   => 220
+                    ,0x31C   => 220
+                    ,0x31D   => 220
+                    ,0x31E   => 220
+                    ,0x31F   => 220
+                    ,0x320   => 220
+                    ,0x323   => 220
+                    ,0x324   => 220
+                    ,0x325   => 220
+                    ,0x326   => 220
+                    ,0x329   => 220
+                    ,0x32A   => 220
+                    ,0x32B   => 220
+                    ,0x32C   => 220
+                    ,0x32D   => 220
+                    ,0x32E   => 220
+                    ,0x32F   => 220
+                    ,0x330   => 220
+                    ,0x331   => 220
+                    ,0x332   => 220
+                    ,0x333   => 220
+                    ,0x339   => 220
+                    ,0x33A   => 220
+                    ,0x33B   => 220
+                    ,0x33C   => 220
+                    ,0x347   => 220
+                    ,0x348   => 220
+                    ,0x349   => 220
+                    ,0x34D   => 220
+                    ,0x34E   => 220
+                    ,0x353   => 220
+                    ,0x354   => 220
+                    ,0x355   => 220
+                    ,0x356   => 220
+                    ,0x591   => 220
+                    ,0x596   => 220
+                    ,0x59B   => 220
+                    ,0x5A3   => 220
+                    ,0x5A4   => 220
+                    ,0x5A5   => 220
+                    ,0x5A6   => 220
+                    ,0x5A7   => 220
+                    ,0x5AA   => 220
+                    ,0x655   => 220
+                    ,0x656   => 220
+                    ,0x6E3   => 220
+                    ,0x6EA   => 220
+                    ,0x6ED   => 220
+                    ,0x731   => 220
+                    ,0x734   => 220
+                    ,0x737   => 220
+                    ,0x738   => 220
+                    ,0x739   => 220
+                    ,0x73B   => 220
+                    ,0x73C   => 220
+                    ,0x73E   => 220
+                    ,0x742   => 220
+                    ,0x744   => 220
+                    ,0x746   => 220
+                    ,0x748   => 220
+                    ,0x952   => 220
+                    ,0xF18   => 220
+                    ,0xF19   => 220
+                    ,0xF35   => 220
+                    ,0xF37   => 220
+                    ,0xFC6   => 220
+                    ,0x193B  => 220
+                    ,0x20E8  => 220
+                    ,0x1D17B => 220
+                    ,0x1D17C => 220
+                    ,0x1D17D => 220
+                    ,0x1D17E => 220
+                    ,0x1D17F => 220
+                    ,0x1D180 => 220
+                    ,0x1D181 => 220
+                    ,0x1D182 => 220
+                    ,0x1D18A => 220
+                    ,0x1D18B => 220
+                    ,0x59A   => 222
+                    ,0x5AD   => 222
+                    ,0x1929  => 222
+                    ,0x302D  => 222
+                    ,0x302E  => 224
+                    ,0x302F  => 224
+                    ,0x1D16D => 226
+                    ,0x5AE   => 228
+                    ,0x18A9  => 228
+                    ,0x302B  => 228
+                    ,0x300   => 230
+                    ,0x301   => 230
+                    ,0x302   => 230
+                    ,0x303   => 230
+                    ,0x304   => 230
+                    ,0x305   => 230
+                    ,0x306   => 230
+                    ,0x307   => 230
+                    ,0x308   => 230
+                    ,0x309   => 230
+                    ,0x30A   => 230
+                    ,0x30B   => 230
+                    ,0x30C   => 230
+                    ,0x30D   => 230
+                    ,0x30E   => 230
+                    ,0x30F   => 230
+                    ,0x310   => 230
+                    ,0x311   => 230
+                    ,0x312   => 230
+                    ,0x313   => 230
+                    ,0x314   => 230
+                    ,0x33D   => 230
+                    ,0x33E   => 230
+                    ,0x33F   => 230
+                    ,0x340   => 230
+                    ,0x341   => 230
+                    ,0x342   => 230
+                    ,0x343   => 230
+                    ,0x344   => 230
+                    ,0x346   => 230
+                    ,0x34A   => 230
+                    ,0x34B   => 230
+                    ,0x34C   => 230
+                    ,0x350   => 230
+                    ,0x351   => 230
+                    ,0x352   => 230
+                    ,0x357   => 230
+                    ,0x363   => 230
+                    ,0x364   => 230
+                    ,0x365   => 230
+                    ,0x366   => 230
+                    ,0x367   => 230
+                    ,0x368   => 230
+                    ,0x369   => 230
+                    ,0x36A   => 230
+                    ,0x36B   => 230
+                    ,0x36C   => 230
+                    ,0x36D   => 230
+                    ,0x36E   => 230
+                    ,0x36F   => 230
+                    ,0x483   => 230
+                    ,0x484   => 230
+                    ,0x485   => 230
+                    ,0x486   => 230
+                    ,0x592   => 230
+                    ,0x593   => 230
+                    ,0x594   => 230
+                    ,0x595   => 230
+                    ,0x597   => 230
+                    ,0x598   => 230
+                    ,0x599   => 230
+                    ,0x59C   => 230
+                    ,0x59D   => 230
+                    ,0x59E   => 230
+                    ,0x59F   => 230
+                    ,0x5A0   => 230
+                    ,0x5A1   => 230
+                    ,0x5A8   => 230
+                    ,0x5A9   => 230
+                    ,0x5AB   => 230
+                    ,0x5AC   => 230
+                    ,0x5AF   => 230
+                    ,0x5C4   => 230
+                    ,0x610   => 230
+                    ,0x611   => 230
+                    ,0x612   => 230
+                    ,0x613   => 230
+                    ,0x614   => 230
+                    ,0x615   => 230
+                    ,0x653   => 230
+                    ,0x654   => 230
+                    ,0x657   => 230
+                    ,0x658   => 230
+                    ,0x6D6   => 230
+                    ,0x6D7   => 230
+                    ,0x6D8   => 230
+                    ,0x6D9   => 230
+                    ,0x6DA   => 230
+                    ,0x6DB   => 230
+                    ,0x6DC   => 230
+                    ,0x6DF   => 230
+                    ,0x6E0   => 230
+                    ,0x6E1   => 230
+                    ,0x6E2   => 230
+                    ,0x6E4   => 230
+                    ,0x6E7   => 230
+                    ,0x6E8   => 230
+                    ,0x6EB   => 230
+                    ,0x6EC   => 230
+                    ,0x730   => 230
+                    ,0x732   => 230
+                    ,0x733   => 230
+                    ,0x735   => 230
+                    ,0x736   => 230
+                    ,0x73A   => 230
+                    ,0x73D   => 230
+                    ,0x73F   => 230
+                    ,0x740   => 230
+                    ,0x741   => 230
+                    ,0x743   => 230
+                    ,0x745   => 230
+                    ,0x747   => 230
+                    ,0x749   => 230
+                    ,0x74A   => 230
+                    ,0x951   => 230
+                    ,0x953   => 230
+                    ,0x954   => 230
+                    ,0xF82   => 230
+                    ,0xF83   => 230
+                    ,0xF86   => 230
+                    ,0xF87   => 230
+                    ,0x170D  => 230
+                    ,0x193A  => 230
+                    ,0x20D0  => 230
+                    ,0x20D1  => 230
+                    ,0x20D4  => 230
+                    ,0x20D5  => 230
+                    ,0x20D6  => 230
+                    ,0x20D7  => 230
+                    ,0x20DB  => 230
+                    ,0x20DC  => 230
+                    ,0x20E1  => 230
+                    ,0x20E7  => 230
+                    ,0x20E9  => 230
+                    ,0xFE20  => 230
+                    ,0xFE21  => 230
+                    ,0xFE22  => 230
+                    ,0xFE23  => 230
+                    ,0x1D185 => 230
+                    ,0x1D186 => 230
+                    ,0x1D187 => 230
+                    ,0x1D189 => 230
+                    ,0x1D188 => 230
+                    ,0x1D1AA => 230
+                    ,0x1D1AB => 230
+                    ,0x1D1AC => 230
+                    ,0x1D1AD => 230
+                    ,0x315   => 232
+                    ,0x31A   => 232
+                    ,0x302C  => 232
+                    ,0x35F   => 233
+                    ,0x362   => 233
+                    ,0x35D   => 234
+                    ,0x35E   => 234
+                    ,0x360   => 234
+                    ,0x361   => 234
+                    ,0x345   => 240
+                    )
+            );
+}
+?>
diff --git a/library/SpamFilter/Core.php b/library/SpamFilter/Core.php
index 9f391530..8b3a3a1f 100644
--- a/library/SpamFilter/Core.php
+++ b/library/SpamFilter/Core.php
@@ -85,7 +85,7 @@ public static function getConfigBinary( $bits = null )
                 {
                     $bits = self::getBitType();
                 }
-            
+
             if ($bits == 64 && (file_exists(BASE_PATH . '/bin/getconfig64'))) {
                     #Zend_Registry::get('logger')->debug("[Core] Using 64-bits getconfig binary");
                     $binary = 'getconfig64';
@@ -132,7 +132,7 @@ public static function getPanelType()
 
             return 'CPANEL';
         }
-                
+
         Zend_Registry::get('logger')->err("[Core] Paneltype cannot be determined.");
 
         return 'UNKNOWN';
@@ -335,14 +335,15 @@ public static function selfCheck( $fullCheck = true, $options = array() )
                     if ($perms != 6755) {
                         //$rv['reason'][] = "APIPass binary has incorrect permissions ({$perms}) instead of 6755. Unable to fix this automatically. Please execute: 'chmod 6755 {$configBinary}' via SSH to fix this.";
                         // Permissions are not correct
-                            $rv = trim( shell_exec( "chown root:root {$configBinary} && chmod +s {$configBinary} && echo \"OK\" || echo \"NOTOK\"") );
-                            if ($rv != "OK")
-                            {
-                                Zend_Registry::get('logger')->emerg("APIPass permissions are not correct ({$perms}). Please chmod it at with +s!");
-                                array_push($rv['reason'], "APIPass binary has incorrect permissions ({$perms}) instead of 6755. Unable to fix this automatically. Please execute: 'chmod +s {$configBinary}' via SSH to fix this.");
-                            } else {
-                                Zend_Registry::get('logger')->info("Fixed the permissions of APIPass, they were '{$perms}' but now changed to '+s'.");
-                            }
+                        $changed = trim( shell_exec( "chown root:root {$configBinary} && chmod +s {$configBinary} && echo \"OK\" || echo \"NOTOK\"") );
+                        if ($changed !== "OK") {
+                            Zend_Registry::get('logger')->emerg("APIPass permissions are not correct ({$perms}). Please chmod it at with +s!");
+                            array_push($rv['reason'],
+                                "APIPass binary has incorrect permissions ({$perms}) instead of 6755. Unable to fix this automatically. Please execute: 'chmod +s {$configBinary}' via SSH to fix this."
+                            );
+                        } else {
+                            Zend_Registry::get('logger')->info("Fixed the permissions of APIPass, they were '{$perms}' but now changed to '+s'.");
+                        }
                     }
                 }
             }
@@ -739,7 +740,7 @@ final static public function isSessionInitRequired()
     {
         return !empty($_SERVER['REQUEST_METHOD']);
     }
-    
+
     final static public function isWindows()
     {
         return stripos(PHP_OS, 'win') === 0;
diff --git a/library/SpamFilter/Diagnostics.php b/library/SpamFilter/Diagnostics.php
index 32076e30..68ac3dd0 100755
--- a/library/SpamFilter/Diagnostics.php
+++ b/library/SpamFilter/Diagnostics.php
@@ -269,12 +269,12 @@ private function check_hooks()
     {
         $return = $this->set_initial_array();
 
-        switch(strtolower($this->_paneltype)){                                       
+        switch(strtolower($this->_paneltype)){
             case "cpanel":
             $panel = new SpamFilter_PanelSupport_Cpanel;
             $registeredHooks = $panel->listHooks();
             $file = BASE_PATH . '/bin/hook.php';
-            $files = array('hook.php' => BASE_PATH . '/bin/hook.php');           
+            $files = array('hook.php' => BASE_PATH . '/bin/hook.php');
             $hooks =  SpamFilter_PanelSupport_Cpanel::getHooksList();
 
             foreach ($hooks as $hook) {
@@ -291,7 +291,7 @@ private function check_hooks()
                 break;
 
         }
-            
+
             foreach ($files as $hook => $file) {
                 $this->_logger->debug("Checking hook: '{$hook}' (file: '{$file}')");
                 // check if the file exists
@@ -303,7 +303,7 @@ private function check_hooks()
                     $return['critical'][] = "The hook '{$hook}' is not executable.";
                 }
             }
-               
+
         // do check here
         return $this->return_result($return);
     }
@@ -459,7 +459,7 @@ private function checkSkip($job)
                 return true;
             }
         }
-        
+
         if (SpamFilter_Core::isWindows()){
             if($job == 'symlink_to_PHP5_binary'){
                 $this->_logger->debug("Skipping check {$job}..");
@@ -472,11 +472,11 @@ private function checkSkip($job)
 
     private function return_result($return)
     {
-        if (count($return['critical']) == 0) {
+        if (is_countable($return['critical']) && count($return['critical']) === 0) {
             unset($return['critical']);
         }
 
-        if (count($return['warning']) == 0) {
+        if (is_countable($return['warning']) && count($return['warning']) === 0) {
             unset($return['warning']);
         }
 
diff --git a/library/SpamFilter/Hooks.php b/library/SpamFilter/Hooks.php
index cf56de3e..f0dadb81 100644
--- a/library/SpamFilter/Hooks.php
+++ b/library/SpamFilter/Hooks.php
@@ -549,7 +549,7 @@ public function DeleteAccount($username)
             'username' => $username
         ));
         //$domains = (!empty($result[0]['domain'])) ? $result['acct'] : null;
-        if (count($result) > 0 && is_array($result))
+        if (is_array($result) && count($result) > 0)
         {
             foreach($result as $domain)
             {
@@ -565,7 +565,8 @@ public function DeleteAccount($username)
             // Aliases are already being processed by the SE-api.
 
             $addonDomains = $this->_panel->getAddonDomains( $username );
-            $this->_logger->debug("[WHM] Domain Removal, " . count($addonDomains) . " addon domains: " . serialize($addonDomains) );
+            $countAddonDomains = is_array($addonDomains) ? count($addonDomains) : 0;
+            $this->_logger->debug("[WHM] Domain Removal, " . $countAddonDomains . " addon domains: " . serialize($addonDomains) );
             if ($addonDomains !== false)
             {
                 foreach ($addonDomains as $key => $addon)
@@ -577,7 +578,8 @@ public function DeleteAccount($username)
             }
 
             $parkedDomains = $this->_panel->getParkedDomains( $username );
-            $this->_logger->debug("[WHM] Domain Removal, " . count($parkedDomains) . " parked domains: " . serialize($parkedDomains) );
+            $countParkedDomains = is_array($parkedDomains) ? count($parkedDomains) : 0;
+            $this->_logger->debug("[WHM] Domain Removal, " . $countParkedDomains . " parked domains: " . serialize($parkedDomains) );
             if ( $parkedDomains !== false )
             {
                 foreach ($parkedDomains as $key => $parked)
@@ -589,7 +591,8 @@ public function DeleteAccount($username)
             }
 
             $subDomains = $this->_panel->getSubDomains( $username );
-            $this->_logger->debug("[WHM] Domain Removal, " . count($subDomains) . " subdomains: " . serialize($subDomains) );
+            $countSubDomains = is_array($subDomains) ? count($subDomains) : 0;
+            $this->_logger->debug("[WHM] Domain Removal, " . $countSubDomains . " subdomains: " . serialize($subDomains) );
             if ( $subDomains !== false )
             {
                 foreach ($subDomains as $key => $subDomain)
@@ -1005,7 +1008,7 @@ public function safeResetDns($domain)
                 }
             }
 
-            if ($recordsRemoved == count($existimgMxRecords)) {
+            if ($recordsRemoved === count($existimgMxRecords)) {
                 $this->_panel->addMxRecord($domain, 10, $this->getFallbackMxRecordHostname());
             }
         }
diff --git a/library/SpamFilter/PanelSupport/Cpanel.php b/library/SpamFilter/PanelSupport/Cpanel.php
index 5bcd63cb..2555b3e5 100755
--- a/library/SpamFilter/PanelSupport/Cpanel.php
+++ b/library/SpamFilter/PanelSupport/Cpanel.php
@@ -410,7 +410,7 @@ public function SetupDNS($data)
 
         // Remove all current MX records
         $this->removeMXRecords($domain);
-        
+
         // Setup DNS for $domain using array $records (key = priority);
         foreach ($records as $prio => $value) {
             if (!empty($value)) {
@@ -461,7 +461,7 @@ private function getSPFRecord($params){
         }
         return $spfrecord;
     }
-    
+
      /**
      * Setup SPF Record for specified domain
      *
@@ -476,9 +476,9 @@ public function SetupSPF($params){
             $this->_logger->debug("Cannot add SPF Record. SPF Record is not set in settings.");
             return false;
         }
-        
+
         $args['domain'] = $params['domain'];
-        $args['api.version'] = '1';        
+        $args['api.version'] = '1';
         $spfrecord = $this->getSPFRecord($args);
         $response = array();
         // SPF Record found in DNS
@@ -502,7 +502,7 @@ public function SetupSPF($params){
         }
         return ($response['metadata']['result'] == 1)? true : false;
     }
-    
+
     /**
      * Remove SPF Record for specified domain
      *
@@ -512,19 +512,19 @@ public function SetupSPF($params){
      *
      * @access public
      */
-    public function RemoveSPF($domain){           
+    public function RemoveSPF($domain){
         $args['domain'] = $domain;
-        $args['api.version'] = '1';        
+        $args['api.version'] = '1';
         $spfrecord = $this->getSPFRecord($args);
         if(isset($spfrecord['txtdata']) && $spfrecord['txtdata'] == $this->_config->spf_record){
            $args['zone']    = $domain;
            $args['line']    = $spfrecord['Line'];
            $response = $this->_api->getWhm()->makeQuery('removezonerecord', $args)->getResponse('array');//check status
-           return ($response['metadata']['result'] == 1)? true : false;         
+           return ($response['metadata']['result'] == 1)? true : false;
         }
         return false;
     }
-  
+
      /**
      * Switches MX mode to a different mode.
      *
@@ -554,7 +554,7 @@ public function SwitchMXmode($params)
         } else {
             $user = $params['user'];
         }
-        
+
         if ($user !== false) {
             $this->_logger->debug("Switching MX mode for '{$domain}' to '{$mode}'..");
             try {
@@ -935,7 +935,7 @@ public function getUsersDomains($data)
         // Return a unique array, since the OWNER= can also contain USER=
         $unique = $this->getUniqueDomains($localDomains);
 
-        $c = count($unique);
+        $c = is_array($unique) ? count($unique) : 0;
         $this->_logger->debug("Returning {$c} domains");
         return $unique;
     }
@@ -1006,17 +1006,17 @@ private function listaccts($params = array())
         }
 
         $this->_logger->debug("ListAccts. Search: '{$search}' with value '{$searchby}'.");
-        
+
         try {
-            /** @var $response Cpanel_Query_Object */        
+            /** @var $response Cpanel_Query_Object */
             if ('^root$' == $searchby && $this->permitted('all')){
                 $response = $this->_api->whm_api('listaccts');
-                $arr = $response->getResponse('array');                
+                $arr = $response->getResponse('array');
             } else {
                 $response = $this->_api->whm_api('listaccts', array('search' => $search, 'searchby' => $searchby));
-            
+
                 $arr = $response->getResponse('array');
-                
+
                 // look for owner domains too.
                 if($search == 'owner'){
                     $this->_logger->debug("Search for owner '{$searchby}' account data.");
@@ -1024,9 +1024,9 @@ private function listaccts($params = array())
                     $resellerArr = $resellerResponse->getResponse('array');
                     $arr['acct'][] = $resellerArr['acct'][0];
                 }
-            
+
             }
-            
+
             $this->_logger->info("Data returned: " . serialize($arr));
 
             if (isset($arr['data']) && isset($arr['data']['reason']) && isset($arr['data']['result'])
@@ -1270,7 +1270,7 @@ private function getLocalAccounts()
     {
         $this->_logger->debug("Get local accounts");
         $accounts = $this->listaccts();
-        if (isset($accounts['acct'])) {
+        if (isset($accounts['acct']) && is_array($accounts['acct'])) {
             $c = count($accounts['acct']);
             $this->_logger->debug("Returning {$c} local accounts");
 
@@ -1397,16 +1397,16 @@ public function getParkedDomains($username)
         }
         return (!empty($result) ? $result : false);
     }
-    
+
     public function getSubDomains($username){
         $result = array();
-        $filename = "/var/cpanel/userdata/{$username}/main";     
+        $filename = "/var/cpanel/userdata/{$username}/main";
         if (!file_exists($filename) || !is_readable($filename)) {
             $this->_logger->warn("Failed to retrieve parked domains for '$username': unable to read '{$filename}'. Retrieving parked domains via API.");
             $params = array (   'cpanel_jsonapi_func'       => 'listsubdomains',
                                 'cpanel_jsonapi_apiversion' => 2,
                                 'cpanel_jsonapi_module'     => 'SubDomain',
-                                'user'                      => $username, 
+                                'user'                      => $username,
                             );
             $response = $this->_api->getWhm()->makeQuery('cpanel', $params);
             $domains = $response->getResponse('array');
@@ -1432,7 +1432,7 @@ public function getSubDomains($username){
                 $sectionHasStarted = (0 === strpos($line, 'sub_domains:'));
             }
         }
-        return (!empty($result) ? $result : false);        
+        return (!empty($result) ? $result : false);
     }
 
     /**
@@ -1599,7 +1599,7 @@ public function getResellers($raw = false)
             }
         } catch (Exception $e) {
             $this->_logger->crit("Exception caught in " . __METHOD__ . " method : " . $e->getMessage());
-        }        
+        }
         $this->_logger->debug("Returning array of resellers: " . serialize($output));
 
         return $output;
@@ -1678,7 +1678,7 @@ public function getAccountDomains($params)
                 $domains[$key]['domain']   = $data['domain'];
                 $domains[$key]['username'] = $data['user'];
             }
-            
+
             return $domains;
         }
 
@@ -1860,7 +1860,7 @@ public function IsRemoteDomain($params)
             $this->_logger->debug("{$domain}'s MX mode guessing: the check is skipped due to empty user");
         }
 
-        $is_remote_flag = (array_sum($is_remote) > 0 || count($is_remote) == 0) ? true : false;
+        $is_remote_flag = (array_sum($is_remote) > 0 || count($is_remote) === 0) ? true : false;
 
         $this->_logger->debug("{$domain} is " . ((!$is_remote_flag) ? "NOT " : "") . "a remote domain");
 
@@ -1884,17 +1884,17 @@ public function isInFilter($domain, $ownerDomain = '')
             return true;
         }
         if(!empty($ownerDomain) && SpamFilter_Domain::exists($ownerDomain)){
-            $this->_logger->debug("[isInFilter] Checking for alias of domain '{$ownerDomain}'");                
+            $this->_logger->debug("[isInFilter] Checking for alias of domain '{$ownerDomain}'");
             $SEAPI = new SpamFilter_ResellerAPI;
             $apiResponse = $SEAPI->domainalias()->list(array('domain' => $ownerDomain));
             foreach($apiResponse as $alias){
                 if($alias == $domain){
-                    $this->_logger->debug("[isInFilter] The domain '{$domain}' is alias of domain $ownerDomain.");                
+                    $this->_logger->debug("[isInFilter] The domain '{$domain}' is alias of domain $ownerDomain.");
                     return true;
                 }
             }
         }
-        
+
         $this->_logger->debug("[isInFilter] The domain '{$domain}' is NOT in the filter, or request failed.");
 
         return false;
@@ -1927,7 +1927,7 @@ public function getDomainUser($domain)
                     }
                 }
             }
-        }                
+        }
 
         $domain = strtolower($domain);
 
@@ -2145,8 +2145,8 @@ public function generatePluginConfig($brandname = null, $brandicon = null)
                 shell_exec("/usr/local/cpanel/scripts/install_plugin {$buttonConfig} --theme paper_lantern");
 
                 $this->_logger->debug("[Cpanel] Re-registering plugin for other themes & generating sprites.");
-                
-                // Creating dynamicui directory 
+
+                // Creating dynamicui directory
                 // @see https://trac.spamexperts.com/ticket/22354
                 if(!file_exists('/usr/local/cpanel/base/frontend/x3/dynamicui')){
                     mkdir('/usr/local/cpanel/base/frontend/x3/dynamicui');
@@ -2248,7 +2248,7 @@ public function getCollectionDomains($informer = false)
                                     );
                                 }
                             }
-                            
+
                             /*
                                 Add Addon Domains.
                             */
@@ -2270,10 +2270,10 @@ public function getCollectionDomains($informer = false)
                                     );
                                 }
                             }
-                            
+
                             /*
                                 Add Subomains.
-                            */                            
+                            */
                             if ($informer && isset($sessionManager)) {
                                 $sessionManager->bulkprotectinformer = 'Getting list of subdomains...';
                             }
@@ -2319,7 +2319,7 @@ public function getCollectionDomains($informer = false)
 
         if ($informer && isset($sessionManager)) {
             $sessionManager->bulkprotectinformerstatus = 'protecting';
-            if (0 < count($collectionDomains)) {
+            if (is_array($collectionDomains) && 0 < count($collectionDomains)) {
                 $sessionManager->bulkprotectinformer
                     = 'List of domains has completed. Starting the process of protecting...';
             }
@@ -2407,12 +2407,13 @@ public function migrateDomainsTo($params)
             $domains[] = $collectionDomain['name'];
         }
 
-        if (count($domains) > 0) {
+        $countDomains = count($domains);
+        if ($countDomains > 0) {
             $this->_logger->info("Starting migration.");
             $hook       = new SpamFilter_Hooks;
             $freelimit  = $hook->GetFreeLimit($username, $password);
             $is_success = false;
-            if ('unlimit' == $freelimit || $freelimit - count($domains) >= 0) {
+            if ('unlimit' == $freelimit || $freelimit - $countDomains >= 0) {
                 $limitdomain = null;
                 $notmoved    = array();
                 $moved       = array();
@@ -2587,7 +2588,7 @@ public function getSortedDomains($params)
 
         return false;
     }
-    
+
      /**
      * Returns domains matched with filter
      *
@@ -2596,7 +2597,7 @@ public function getSortedDomains($params)
      * @return array
      *
      * @access public
-     */        
+     */
     public function filterDomains($params){
             $filter = $params['filter'];
             $filteredDomains = array();
@@ -2718,7 +2719,7 @@ public function hasFeatureEnabled($domain) {
         // Check if API request is successful
         // It is required for older versions of WHM & cPanel (below 11.46) where read_featurelist request is unavailble.
         // Check if feature is not avaible OR spamfilter is not on the feature lists.
-        if($arr['metadata']['result'] == 0 || !isset($arr['data']['features']['prospamfilter'])){    
+        if($arr['metadata']['result'] == 0 || !isset($arr['data']['features']['prospamfilter'])){
 		return true;
         }
         return $arr['data']['features']['prospamfilter'] == 1 ? true : false;
@@ -2757,7 +2758,7 @@ public function resellerHasFeatureEnabled($user) {
 
         return $hasFeature;
     }
-    
+
      /**
      * Gather all Installed Hooks
      *
@@ -2773,11 +2774,11 @@ public function listHooks(){
         } else {
             die("Cannot gather hook list! Aborted!");
         }
-    } 
-    
+    }
+
      /**
      * Check if hook is already added into panel
-     * 
+     *
      * @hooks - array with data of hooks
      * @file - script file name
      *
@@ -2800,7 +2801,7 @@ public function isHookExists(array $hooks, $category, $event, $stage, $file)
 
      /**
      * Adding or delete hook using manage_hook functionality
-     * 
+     *
      * @params - array with data of hooks
      * @see guide to standarized hooks at : https://documentation.cpanel.net/display/SDK/Guide+to+Standardized+Hooks+-+Hookable+Events
      *
@@ -2828,11 +2829,11 @@ public function manageHooks($params)
                 }
 
                 system($commandStr);
-            }                        
+            }
         }
         return "Done." . PHP_EOL;
-    } 
-    
+    }
+
     /**
      * Returns main domain of user.
      *
diff --git a/library/SpamFilter/ResellerAPI/Action.php b/library/SpamFilter/ResellerAPI/Action.php
index b74548ac..97951515 100644
--- a/library/SpamFilter/ResellerAPI/Action.php
+++ b/library/SpamFilter/ResellerAPI/Action.php
@@ -411,7 +411,7 @@ public function __call($action, $params)
             if (($this->_controller == 'authticket') || (in_array($action, array('get', 'list')))) {
 
                 // Single entries can be converted to a string instead (e.g. version retrieval)
-                if (count($data['result']) == 1) {
+                if (is_array($data['result']) && count($data['result']) === 1) {
                     $logger->debug("[API] Single array item, converting to string instead. ");
 
                     return $data['result'];
diff --git a/library/Zend/Json.php b/library/Zend/Json.php
index 4ef2b436..36d7f0e5 100644
--- a/library/Zend/Json.php
+++ b/library/Zend/Json.php
@@ -150,9 +150,10 @@ public static function encode($valueToEncode, $cycleCheck = false, $options = ar
         }
 
         //only do post-proccessing to revert back the Zend_Json_Expr if any.
-        if (count($javascriptExpressions) > 0) {
-            $count = count($javascriptExpressions);
-            for($i = 0; $i < $count; $i++) {
+
+        $countJavascriptExpressions = is_array($javascriptExpressions) ? count($javascriptExpressions) : 0;
+        if ($countJavascriptExpressions > 0) {
+            for($i = 0; $i < $countJavascriptExpressions; $i++) {
                 $magicKey = $javascriptExpressions[$i]['magicKey'];
                 $value    = $javascriptExpressions[$i]['value'];
 
@@ -268,14 +269,14 @@ protected static function _processXml($simpleXmlElementObject, $ignoreXmlAttribu
         $value = self::_getXmlValue($simpleXmlElementObject);
         $attributes = (array) $simpleXmlElementObject->attributes();
 
-        if (count($children) == 0) {
+        if (is_countable($children) && count($children) === 0) {
             if (!empty($attributes) && !$ignoreXmlAttributes) {
                 foreach ($attributes['@attributes'] as $k => $v) {
                     $attributes['@attributes'][$k]= self::_getXmlValue($v);
                 }
                 if (!empty($value)) {
                     $attributes['@text'] = $value;
-                } 
+                }
                 return array($name => $attributes);
             } else {
                return array($name => $value);
@@ -356,7 +357,7 @@ public static function fromXml($xmlStringContents, $ignoreXmlAttributes=true)
         return($jsonStringOutput);
     }
 
-    
+
 
     /**
      * Pretty-print JSON string
@@ -420,9 +421,9 @@ public static function prettyPrint($json, $options = array())
                 $result .= $token . $lineBreak;
             } else {
                 $result .= ( $inLiteral ? '' : $prefix ) . $token;
-                
+
                 // Count # of unescaped double-quotes in token, subtract # of
-                // escaped double-quotes and if the result is odd then we are 
+                // escaped double-quotes and if the result is odd then we are
                 // inside a string literal
                 if ((substr_count($token, "\"")-substr_count($token, "\\\"")) % 2 != 0) {
                     $inLiteral = !$inLiteral;
diff --git a/library/functions.php b/library/functions.php
index d4ac14a5..deae2156 100755
--- a/library/functions.php
+++ b/library/functions.php
@@ -1,485 +1,491 @@
-<?php
-/*
-*************************************************************************
-*                                                                       *
-* ProSpamFilter2                                                        *
-* Bridge between Webhosting panels & SpamExperts filtering			    *
-*                                                                       *
-* Copyright (c) 2010 SpamExperts B.V. All Rights Reserved,              *
-*                                                                       *
-*************************************************************************
-*                                                                       *
-* Email: support@spamexperts.com                                        *
-* Website: htttp://www.spamexperts.com                                  *
-*                                                                       *
-*************************************************************************
-*                                                                       *
-* This software is furnished under a license and may be used and copied *
-* only in accordance with the  terms of such license and with the       *
-* inclusion of the above copyright notice. No title to and ownership    *
-* of the software is  hereby  transferred.                              *
-*                                                                       *
-* You may not reverse engineer, decompile or disassemble this software  * 
-* product or software product license.                                  *
-*                                                                       *
-* SpamExperts may terminate this license if you don't comply with any   *
-* of the terms and conditions set forth in our end user                 *
-* license agreement (EULA). In such event, licensee agrees to return    *
-* licensor  or destroy  all copies of software upon termination of the  *
-* license.                                                              *
-*                                                                       *
-* Please see the EULA file for the full End User License Agreement.     *
-*                                                                       *
-*************************************************************************
-*/
-	if( !function_exists( "wl" ) )
-	{
-		function wl($txt)
-		{
-			echo "{$wl}\n";
-		}
-	}
-	
-	if( !function_exists( "bcdiv" ) ) //<-- This function *might* exist in PHP already. Or atleas customers' PHP
-	{
-		function bcdiv( $first, $second, $scale = 0 )
-		{
-			$res = $first / $second;
-			return round( $res, $scale );
-		}
-	}
-
-	if( !function_exists( "_sort_by_dots_qty_rev" ) )
-	{		
-		function _sort_by_dots_qty_rev($d1, $d2)
-		{
-			$dots1 = substr_count($d1, '.');
-			$dots2 = substr_count($d2, '.');
-
-			if ($dots1 == $dots2) {
-				return 0;
-			} elseif ($dots1 > $dots2) {
-				return -1;
-			} else {
-				return 1;
-			}
-		}
-	}
-
-	if( !function_exists( "simpleXMLToArray" ) )
-	{			
-		function simpleXMLToArray($xml,$flattenValues=true,$flattenAttributes = true,$flattenChildren=true,$valueKey='@value',$attributesKey='@attributes',	$childrenKey='@children')
-		{
-			$return = array();
-			if(!($xml instanceof SimpleXMLElement)){return $return;}
-			$name = $xml->getName();
-			$_value = trim((string)$xml);
-			if(strlen($_value)==0){$_value = null;};
-
-			if($_value!==null){
-				if(!$flattenValues){$return[$valueKey] = $_value;}
-				else{$return = $_value;}
-			}
-
-			$children = array();
-			$first = true;
-			foreach($xml->children() as $elementName => $child){
-				$value = simpleXMLToArray($child, $flattenValues, $flattenAttributes, $flattenChildren, $valueKey, $attributesKey, $childrenKey);
-				if(isset($children[$elementName])){
-					if($first){
-						$temp = $children[$elementName];
-						unset($children[$elementName]);
-						$children[$elementName][] = $temp;
-						$first=false;
-					}
-					$children[$elementName][] = $value;
-				}
-				else{
-					$children[$elementName] = $value;
-				}
-			}
-			if(count($children)>0){
-				if(!$flattenChildren){$return[$childrenKey] = $children;}
-				else{$return = array_merge($return,$children);}
-			}
-
-			$attributes = array();
-			foreach($xml->attributes() as $name=>$value){
-				$attributes[$name] = trim($value);
-			}
-			if(count($attributes)>0){
-				if(!$flattenAttributes){$return[$attributesKey] = $attributes;}
-				else{$return = array_merge($return, $attributes);}
-			}
-		   
-			return $return;
-		}
-	}
-
-	if( !function_exists( "argv2array" ) )
-	{			
-		function argv2array ($argv)
-		{
-			$opts = array();
-			$argv0 = array_shift($argv);
-
-			while(count($argv))
-			{
-				$key = array_shift($argv);
-				$value = array_shift($argv);
-				$opts[$key] = $value;
-			}
-			return $opts;
-		}
-	}
-
-
-	//
-	if( !function_exists( "xml2array" ) )
-	{		
-		function xml2array($contents, $get_attributes=1, $priority = 'tag') {
-			if(!$contents) return array();
-
-			if(!function_exists('xml_parser_create')) {
-				//print "'xml_parser_create()' function not found!";
-				return array();
-			}
-
-			//Get the XML parser of PHP - PHP must have this module for the parser to work
-			$parser = xml_parser_create('');
-			xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); # http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
-			xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
-			xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
-			xml_parse_into_struct($parser, trim($contents), $xml_values);
-			xml_parser_free($parser);
-
-			if(!$xml_values) return;//Hmm...
-
-			//Initializations
-			$xml_array = array();
-			$parents = array();
-			$opened_tags = array();
-			$arr = array();
-
-			$current = &$xml_array; //Refference
-
-			//Go through the tags.
-			$repeated_tag_index = array();//Multiple tags with same name will be turned into an array
-			foreach($xml_values as $data) {
-				unset($attributes,$value);//Remove existing values, or there will be trouble
-
-				//This command will extract these variables into the foreach scope
-				// tag(string), type(string), level(int), attributes(array).
-				extract($data);//We could use the array by itself, but this cooler.
-
-				$result = array();
-				$attributes_data = array();
-				
-				if(isset($value)) {
-					if($priority == 'tag') $result = $value;
-					else $result['value'] = $value; //Put the value in a assoc array if we are in the 'Attribute' mode
-				}
-
-				//Set the attributes too.
-				if(isset($attributes) and $get_attributes) {
-					foreach($attributes as $attr => $val) {
-						if($priority == 'tag') $attributes_data[$attr] = $val;
-						else $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr'
-					}
-				}
-
-				//See tag status and do the needed.
-				if($type == "open") {//The starting of the tag '<tag>'
-					$parent[$level-1] = &$current;
-					if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag
-						$current[$tag] = $result;
-						if($attributes_data) $current[$tag. '_attr'] = $attributes_data;
-						$repeated_tag_index[$tag.'_'.$level] = 1;
-
-						$current = &$current[$tag];
-
-					} else { //There was another element with the same tag name
-
-						if(isset($current[$tag][0])) {//If there is a 0th element it is already an array
-							$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
-							$repeated_tag_index[$tag.'_'.$level]++;
-						} else {//This section will make the value an array if multiple tags with the same name appear together
-							$current[$tag] = array($current[$tag],$result);//This will combine the existing item and the new item together to make an array
-							$repeated_tag_index[$tag.'_'.$level] = 2;
-							
-							if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well
-								$current[$tag]['0_attr'] = $current[$tag.'_attr'];
-								unset($current[$tag.'_attr']);
-							}
-
-						}
-						$last_item_index = $repeated_tag_index[$tag.'_'.$level]-1;
-						$current = &$current[$tag][$last_item_index];
-					}
-
-				} elseif($type == "complete") { //Tags that ends in 1 line '<tag />'
-					//See if the key is already taken.
-					if(!isset($current[$tag])) { //New Key
-						$current[$tag] = $result;
-						$repeated_tag_index[$tag.'_'.$level] = 1;
-						if($priority == 'tag' and $attributes_data) $current[$tag. '_attr'] = $attributes_data;
-
-					} else { //If taken, put all things inside a list(array)
-						if(isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array...
-
-							// ...push the new element into that array.
-							$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
-							
-							if($priority == 'tag' and $get_attributes and $attributes_data) {
-								$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
-							}
-							$repeated_tag_index[$tag.'_'.$level]++;
-
-						} else { //If it is not an array...
-							$current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value
-							$repeated_tag_index[$tag.'_'.$level] = 1;
-							if($priority == 'tag' and $get_attributes) {
-								if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well
-									
-									$current[$tag]['0_attr'] = $current[$tag.'_attr'];
-									unset($current[$tag.'_attr']);
-								}
-								
-								if($attributes_data) {
-									$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
-								}
-							}
-							$repeated_tag_index[$tag.'_'.$level]++; //0 and 1 index is already taken
-						}
-					}
-
-				} elseif($type == 'close') { //End of tag '</tag>'
-					$current = &$parent[$level-1];
-				}
-			}
-			
-			return($xml_array);
-		} 
-	}
-
-if( !function_exists( "smartCopy" ) )
-{	
-    function smartCopy($source, $dest, $options=array('folderPermission'=>0755,'filePermission'=>0644))
-    {
-        $result=false;
-                 
-        if (is_file($source)) 
-		{
-            if ($dest[strlen($dest)-1]== DS )
-			{
-                if (!file_exists($dest)) 
-				{
-					// PHP5 mkdir function supports recursive, so just use that
-					mkdir($dest,$options['folderPermission'],true);
-                }
-                $__dest=$dest.DS.basename($source);
-            }
-			else 
-			{
-                $__dest=$dest;
-            }
-            $result=copy($source, $__dest);
-            chmod($__dest,$options['filePermission']);
-           
-        } 
-		elseif(is_dir($source)) 
-		{
-            if ($dest[strlen($dest)-1]== DS ) 
-			{
-                if ($source[strlen($source)-1]== DS ) 
-				{
-                    //Copy only contents
-                }
-				else 
-				{
-                    //Change parent itself and its contents
-                    $dest=$dest.basename($source);
-                    @mkdir($dest,$options['folderPermission']);
-                }
-            } 
-			else 
-			{
-                if ($source[strlen($source)-1]== DS ) 
-				{
-                    //Copy parent directory with new name and all its content
-                    @mkdir($dest,$options['folderPermission']);
-                }
-				else 
-				{
-                    //Copy parent directory with new name and all its content
-                    @mkdir($dest,$options['folderPermission']);
-                }
-            }
-
-            $dirHandle=opendir($source);
-            while($file=readdir($dirHandle))
-            {
-                if($file!="." && $file!=".." && (!strstr($file, ".svn")) )
-                {
-                    $result=smartCopy($source.DS.$file, $dest.DS.$file, $options);
-                }
-            }
-            closedir($dirHandle);
-           
-        }
-		else
-		{
-            $result=false;
-        }
-        return $result;
-    } 	
-}
-
-if (! function_exists('isWindows')) {
-    function isWindows() {
-        return stripos(PHP_OS, 'win') === 0;
-    }
-}
-
-if( !function_exists( "rrmdir" ) )	
-{
-	 function rrmdir($dir)
-	 {
-         if (isWindows()) {
-             system("rmdir $dir /s /q");
-         } else {
-             system("rm -rf $dir");
-         }
-	 }
-}
-
-if( !function_exists( "is_cli" ) )	
-{
-	function is_cli() 
-	{ 
-		if ( !isset($_SERVER['HTTP_USER_AGENT']) )
-		{ 
-			return true; 
-		} else { 
-			return false; 
-		} 
-	}
-}
-
-if( !function_exists( "file_perms" ) )
-{
-	function file_perms($file, $octal = false)
-	{
-		if(!file_exists($file)) return false;
-		try {
-			$perms = fileperms($file);
-		} catch (Exception $e) {
-			// It failed. Horribly!
-			return false;
-		}
-		$cut = $octal ? 2 : 3;
-		return substr(decoct($perms), $cut);
-	}
-}
-
-if( !function_exists( "clean_domain" ) )
-{
-	function clean_domain( $domain )
-	{
-		// Lowercase it & trim it.
-		$domain = strtolower( trim( $domain ) );
-		
-		// Explode it by the separator
-		$x = explode('.', $domain);
-		if(is_array($x))
-		{
-			// If the first part of the URL is "www"..
-			if ($x[0] == "www")
-			{
-				// chop it off.
-				unset( $x[0] );
-
-				// Re-form the domain and give it back!
-				return implode( '.', $x );
-			}
-		}
-		// Return the domain (lowercased & trimmed) since it apparently did not contain "www." to begin with.
-		return $domain;
-	}
-}
-
-if( !function_exists( "array_sort" ) )
-{
-	function array_sort($array, $on, $order=SORT_ASC)
-	{
-		$new_array = array();
-		$sortable_array = array();
-
-		if (count($array) > 0 && is_array($array)) 
-		{
-			foreach ($array as $k => $v) 
-			{
-				if (is_array($v)) 
-				{
-					foreach ($v as $k2 => $v2) 
-					{
-						if ($k2 == $on) {
-							$sortable_array[$k] = $v2;
-						}
-					}
-				} else {
-					$sortable_array[$k] = $v;
-				}
-			}
-
-			switch ($order) 
-			{
-				case SORT_ASC:
-					asort($sortable_array);
-				break;
-				case SORT_DESC:
-					arsort($sortable_array);
-				break;
-			}
-
-			foreach ($sortable_array as $k => $v) 
-			{
-				$new_array[$k] = $array[$k];
-			}
-		}
-
-		return $new_array;
-	}
-}
-
-// Workaround for [ZF-9088] and missing parse_ini_string for PHP < 5.3.0
-if( !function_exists('parse_ini_string') )
-{   
-    function parse_ini_string( $string ) 
-	{
-        $array = Array();
-
-        $lines = explode("\n", $string );
-       
-        foreach( $lines as $line ) {
-            $statement = preg_match(
-"/^(?!;)(?P<key>[\w+\.\-]+?)\s*=\s*(?P<value>.+?)\s*$/", $line, $match );
-
-            if( $statement ) 
-			{
-                $key    = $match[ 'key' ];
-                $value    = $match[ 'value' ];
-               
-                # Remove quote
-                if( preg_match( "/^\".*\"$/", $value ) || preg_match( "/^'.*'$/", $value ) ) 
-				{
-                    $value = mb_substr( $value, 1, mb_strlen( $value ) - 2 );
-                }
-               
-                $array[ $key ] = $value;
-            }
-        }
-        return $array;
-    }
-}
-?>
\ No newline at end of file
+<?php
+/*
+*************************************************************************
+*                                                                       *
+* ProSpamFilter2                                                        *
+* Bridge between Webhosting panels & SpamExperts filtering			    *
+*                                                                       *
+* Copyright (c) 2010 SpamExperts B.V. All Rights Reserved,              *
+*                                                                       *
+*************************************************************************
+*                                                                       *
+* Email: support@spamexperts.com                                        *
+* Website: htttp://www.spamexperts.com                                  *
+*                                                                       *
+*************************************************************************
+*                                                                       *
+* This software is furnished under a license and may be used and copied *
+* only in accordance with the  terms of such license and with the       *
+* inclusion of the above copyright notice. No title to and ownership    *
+* of the software is  hereby  transferred.                              *
+*                                                                       *
+* You may not reverse engineer, decompile or disassemble this software  *
+* product or software product license.                                  *
+*                                                                       *
+* SpamExperts may terminate this license if you don't comply with any   *
+* of the terms and conditions set forth in our end user                 *
+* license agreement (EULA). In such event, licensee agrees to return    *
+* licensor  or destroy  all copies of software upon termination of the  *
+* license.                                                              *
+*                                                                       *
+* Please see the EULA file for the full End User License Agreement.     *
+*                                                                       *
+*************************************************************************
+*/
+	if( !function_exists( "wl" ) )
+	{
+		function wl($txt)
+		{
+			echo "{$wl}\n";
+		}
+	}
+
+	if( !function_exists( "bcdiv" ) ) //<-- This function *might* exist in PHP already. Or atleas customers' PHP
+	{
+		function bcdiv( $first, $second, $scale = 0 )
+		{
+			$res = $first / $second;
+			return round( $res, $scale );
+		}
+	}
+
+	if( !function_exists( "_sort_by_dots_qty_rev" ) )
+	{
+		function _sort_by_dots_qty_rev($d1, $d2)
+		{
+			$dots1 = substr_count($d1, '.');
+			$dots2 = substr_count($d2, '.');
+
+			if ($dots1 == $dots2) {
+				return 0;
+			} elseif ($dots1 > $dots2) {
+				return -1;
+			} else {
+				return 1;
+			}
+		}
+	}
+
+	if( !function_exists( "simpleXMLToArray" ) )
+	{
+		function simpleXMLToArray($xml,$flattenValues=true,$flattenAttributes = true,$flattenChildren=true,$valueKey='@value',$attributesKey='@attributes',	$childrenKey='@children')
+		{
+			$return = array();
+			if(!($xml instanceof SimpleXMLElement)){return $return;}
+			$name = $xml->getName();
+			$_value = trim((string)$xml);
+			if(strlen($_value)==0){$_value = null;};
+
+			if($_value!==null){
+				if(!$flattenValues){$return[$valueKey] = $_value;}
+				else{$return = $_value;}
+			}
+
+			$children = array();
+			$first = true;
+			foreach($xml->children() as $elementName => $child){
+				$value = simpleXMLToArray($child, $flattenValues, $flattenAttributes, $flattenChildren, $valueKey, $attributesKey, $childrenKey);
+				if(isset($children[$elementName])){
+					if($first){
+						$temp = $children[$elementName];
+						unset($children[$elementName]);
+						$children[$elementName][] = $temp;
+						$first=false;
+					}
+					$children[$elementName][] = $value;
+				}
+				else{
+					$children[$elementName] = $value;
+				}
+			}
+			if(count($children)>0){
+				if(!$flattenChildren){$return[$childrenKey] = $children;}
+				else{$return = array_merge($return,$children);}
+			}
+
+			$attributes = array();
+			foreach($xml->attributes() as $name=>$value){
+				$attributes[$name] = trim($value);
+			}
+			if(count($attributes)>0){
+				if(!$flattenAttributes){$return[$attributesKey] = $attributes;}
+				else{$return = array_merge($return, $attributes);}
+			}
+
+			return $return;
+		}
+	}
+
+	if( !function_exists( "argv2array" ) )
+	{
+		function argv2array ($argv)
+		{
+			$opts = array();
+			$argv0 = array_shift($argv);
+
+			while(count($argv))
+			{
+				$key = array_shift($argv);
+				$value = array_shift($argv);
+				$opts[$key] = $value;
+			}
+			return $opts;
+		}
+	}
+
+
+	//
+	if( !function_exists( "xml2array" ) )
+	{
+		function xml2array($contents, $get_attributes=1, $priority = 'tag') {
+			if(!$contents) return array();
+
+			if(!function_exists('xml_parser_create')) {
+				//print "'xml_parser_create()' function not found!";
+				return array();
+			}
+
+			//Get the XML parser of PHP - PHP must have this module for the parser to work
+			$parser = xml_parser_create('');
+			xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); # http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
+			xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
+			xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
+			xml_parse_into_struct($parser, trim($contents), $xml_values);
+			xml_parser_free($parser);
+
+			if(!$xml_values) return;//Hmm...
+
+			//Initializations
+			$xml_array = array();
+			$parents = array();
+			$opened_tags = array();
+			$arr = array();
+
+			$current = &$xml_array; //Refference
+
+			//Go through the tags.
+			$repeated_tag_index = array();//Multiple tags with same name will be turned into an array
+			foreach($xml_values as $data) {
+				unset($attributes,$value);//Remove existing values, or there will be trouble
+
+				//This command will extract these variables into the foreach scope
+				// tag(string), type(string), level(int), attributes(array).
+				extract($data);//We could use the array by itself, but this cooler.
+
+				$result = array();
+				$attributes_data = array();
+
+				if(isset($value)) {
+					if($priority == 'tag') $result = $value;
+					else $result['value'] = $value; //Put the value in a assoc array if we are in the 'Attribute' mode
+				}
+
+				//Set the attributes too.
+				if(isset($attributes) and $get_attributes) {
+					foreach($attributes as $attr => $val) {
+						if($priority == 'tag') $attributes_data[$attr] = $val;
+						else $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr'
+					}
+				}
+
+				//See tag status and do the needed.
+				if($type == "open") {//The starting of the tag '<tag>'
+					$parent[$level-1] = &$current;
+					if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag
+						$current[$tag] = $result;
+						if($attributes_data) $current[$tag. '_attr'] = $attributes_data;
+						$repeated_tag_index[$tag.'_'.$level] = 1;
+
+						$current = &$current[$tag];
+
+					} else { //There was another element with the same tag name
+
+						if(isset($current[$tag][0])) {//If there is a 0th element it is already an array
+							$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
+							$repeated_tag_index[$tag.'_'.$level]++;
+						} else {//This section will make the value an array if multiple tags with the same name appear together
+							$current[$tag] = array($current[$tag],$result);//This will combine the existing item and the new item together to make an array
+							$repeated_tag_index[$tag.'_'.$level] = 2;
+
+							if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well
+								$current[$tag]['0_attr'] = $current[$tag.'_attr'];
+								unset($current[$tag.'_attr']);
+							}
+
+						}
+						$last_item_index = $repeated_tag_index[$tag.'_'.$level]-1;
+						$current = &$current[$tag][$last_item_index];
+					}
+
+				} elseif($type == "complete") { //Tags that ends in 1 line '<tag />'
+					//See if the key is already taken.
+					if(!isset($current[$tag])) { //New Key
+						$current[$tag] = $result;
+						$repeated_tag_index[$tag.'_'.$level] = 1;
+						if($priority == 'tag' and $attributes_data) $current[$tag. '_attr'] = $attributes_data;
+
+					} else { //If taken, put all things inside a list(array)
+						if(isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array...
+
+							// ...push the new element into that array.
+							$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
+
+							if($priority == 'tag' and $get_attributes and $attributes_data) {
+								$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
+							}
+							$repeated_tag_index[$tag.'_'.$level]++;
+
+						} else { //If it is not an array...
+							$current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value
+							$repeated_tag_index[$tag.'_'.$level] = 1;
+							if($priority == 'tag' and $get_attributes) {
+								if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well
+
+									$current[$tag]['0_attr'] = $current[$tag.'_attr'];
+									unset($current[$tag.'_attr']);
+								}
+
+								if($attributes_data) {
+									$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
+								}
+							}
+							$repeated_tag_index[$tag.'_'.$level]++; //0 and 1 index is already taken
+						}
+					}
+
+				} elseif($type == 'close') { //End of tag '</tag>'
+					$current = &$parent[$level-1];
+				}
+			}
+
+			return($xml_array);
+		}
+	}
+
+if( !function_exists( "smartCopy" ) )
+{
+    function smartCopy($source, $dest, $options=array('folderPermission'=>0755,'filePermission'=>0644))
+    {
+        $result=false;
+
+        if (is_file($source))
+		{
+            if ($dest[strlen($dest)-1]== DS )
+			{
+                if (!file_exists($dest))
+				{
+					// PHP5 mkdir function supports recursive, so just use that
+					mkdir($dest,$options['folderPermission'],true);
+                }
+                $__dest=$dest.DS.basename($source);
+            }
+			else
+			{
+                $__dest=$dest;
+            }
+            $result=copy($source, $__dest);
+            chmod($__dest,$options['filePermission']);
+
+        }
+		elseif(is_dir($source))
+		{
+            if ($dest[strlen($dest)-1]== DS )
+			{
+                if ($source[strlen($source)-1]== DS )
+				{
+                    //Copy only contents
+                }
+				else
+				{
+                    //Change parent itself and its contents
+                    $dest=$dest.basename($source);
+                    @mkdir($dest,$options['folderPermission']);
+                }
+            }
+			else
+			{
+                if ($source[strlen($source)-1]== DS )
+				{
+                    //Copy parent directory with new name and all its content
+                    @mkdir($dest,$options['folderPermission']);
+                }
+				else
+				{
+                    //Copy parent directory with new name and all its content
+                    @mkdir($dest,$options['folderPermission']);
+                }
+            }
+
+            $dirHandle=opendir($source);
+            while($file=readdir($dirHandle))
+            {
+                if($file!="." && $file!=".." && (!strstr($file, ".svn")) )
+                {
+                    $result=smartCopy($source.DS.$file, $dest.DS.$file, $options);
+                }
+            }
+            closedir($dirHandle);
+
+        }
+		else
+		{
+            $result=false;
+        }
+        return $result;
+    }
+}
+
+if (! function_exists('isWindows')) {
+    function isWindows() {
+        return stripos(PHP_OS, 'win') === 0;
+    }
+}
+
+if( !function_exists( "rrmdir" ) )
+{
+	 function rrmdir($dir)
+	 {
+         if (isWindows()) {
+             system("rmdir $dir /s /q");
+         } else {
+             system("rm -rf $dir");
+         }
+	 }
+}
+
+if( !function_exists( "is_cli" ) )
+{
+	function is_cli()
+	{
+		if ( !isset($_SERVER['HTTP_USER_AGENT']) )
+		{
+			return true;
+		} else {
+			return false;
+		}
+	}
+}
+
+if( !function_exists( "file_perms" ) )
+{
+	function file_perms($file, $octal = false)
+	{
+		if(!file_exists($file)) return false;
+		try {
+			$perms = fileperms($file);
+		} catch (Exception $e) {
+			// It failed. Horribly!
+			return false;
+		}
+		$cut = $octal ? 2 : 3;
+		return substr(decoct($perms), $cut);
+	}
+}
+
+if( !function_exists( "clean_domain" ) )
+{
+	function clean_domain( $domain )
+	{
+		// Lowercase it & trim it.
+		$domain = strtolower( trim( $domain ) );
+
+		// Explode it by the separator
+		$x = explode('.', $domain);
+		if(is_array($x))
+		{
+			// If the first part of the URL is "www"..
+			if ($x[0] == "www")
+			{
+				// chop it off.
+				unset( $x[0] );
+
+				// Re-form the domain and give it back!
+				return implode( '.', $x );
+			}
+		}
+		// Return the domain (lowercased & trimmed) since it apparently did not contain "www." to begin with.
+		return $domain;
+	}
+}
+
+if( !function_exists( "array_sort" ) )
+{
+	function array_sort($array, $on, $order=SORT_ASC)
+	{
+		$new_array = array();
+		$sortable_array = array();
+
+		if (count($array) > 0 && is_array($array))
+		{
+			foreach ($array as $k => $v)
+			{
+				if (is_array($v))
+				{
+					foreach ($v as $k2 => $v2)
+					{
+						if ($k2 == $on) {
+							$sortable_array[$k] = $v2;
+						}
+					}
+				} else {
+					$sortable_array[$k] = $v;
+				}
+			}
+
+			switch ($order)
+			{
+				case SORT_ASC:
+					asort($sortable_array);
+				break;
+				case SORT_DESC:
+					arsort($sortable_array);
+				break;
+			}
+
+			foreach ($sortable_array as $k => $v)
+			{
+				$new_array[$k] = $array[$k];
+			}
+		}
+
+		return $new_array;
+	}
+}
+
+// Workaround for [ZF-9088] and missing parse_ini_string for PHP < 5.3.0
+if( !function_exists('parse_ini_string') )
+{
+    function parse_ini_string( $string )
+	{
+        $array = Array();
+
+        $lines = explode("\n", $string );
+
+        foreach( $lines as $line ) {
+            $statement = preg_match(
+"/^(?!;)(?P<key>[\w+\.\-]+?)\s*=\s*(?P<value>.+?)\s*$/", $line, $match );
+
+            if( $statement )
+			{
+                $key    = $match[ 'key' ];
+                $value    = $match[ 'value' ];
+
+                # Remove quote
+                if( preg_match( "/^\".*\"$/", $value ) || preg_match( "/^'.*'$/", $value ) )
+				{
+                    $value = mb_substr( $value, 1, mb_strlen( $value ) - 2 );
+                }
+
+                $array[ $key ] = $value;
+            }
+        }
+        return $array;
+    }
+}
+
+// is_countable polyfill for PHP < 7.3.0
+if (!function_exists('is_countable')) {
+    function is_countable($var) {
+        return (is_array($var) || $var instanceof Countable);
+    }
+}