File indexing completed on 2025-01-26 05:25:33
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Text_Table 0017 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0018 * @license http://framework.zend.com/license/new-bsd New BSD License 0019 * @version $Id$ 0020 */ 0021 0022 /** 0023 * @see Zend_Text_Table_Decorator_Interface 0024 */ 0025 // require_once 'Zend/Text/Table/Decorator/Interface.php'; 0026 0027 /** 0028 * Unicode Decorator for Zend_Text_Table 0029 * 0030 * @category Zend 0031 * @package Zend_Text_Table 0032 * @uses Zend_Text_Table_Decorator_Interface 0033 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0034 * @license http://framework.zend.com/license/new-bsd New BSD License 0035 */ 0036 class Zend_Text_Table_Decorator_Unicode implements Zend_Text_Table_Decorator_Interface 0037 { 0038 /** 0039 * Defined by Zend_Text_Table_Decorator_Interface 0040 * 0041 * @return string 0042 */ 0043 public function getTopLeft() 0044 { 0045 return $this->_uniChar(0x250C); 0046 } 0047 0048 /** 0049 * Defined by Zend_Text_Table_Decorator_Interface 0050 * 0051 * @return string 0052 */ 0053 public function getTopRight() 0054 { 0055 return $this->_uniChar(0x2510); 0056 } 0057 0058 /** 0059 * Defined by Zend_Text_Table_Decorator_Interface 0060 * 0061 * @return string 0062 */ 0063 public function getBottomLeft() 0064 { 0065 return $this->_uniChar(0x2514); 0066 } 0067 0068 /** 0069 * Defined by Zend_Text_Table_Decorator_Interface 0070 * 0071 * @return string 0072 */ 0073 public function getBottomRight() 0074 { 0075 return $this->_uniChar(0x2518); 0076 } 0077 0078 /** 0079 * Defined by Zend_Text_Table_Decorator_Interface 0080 * 0081 * @return string 0082 */ 0083 public function getVertical() 0084 { 0085 return $this->_uniChar(0x2502); 0086 } 0087 0088 /** 0089 * Defined by Zend_Text_Table_Decorator_Interface 0090 * 0091 * @return string 0092 */ 0093 public function getHorizontal() 0094 { 0095 return $this->_uniChar(0x2500); 0096 } 0097 0098 /** 0099 * Defined by Zend_Text_Table_Decorator_Interface 0100 * 0101 * @return string 0102 */ 0103 public function getCross() 0104 { 0105 return $this->_uniChar(0x253C); 0106 } 0107 0108 /** 0109 * Defined by Zend_Text_Table_Decorator_Interface 0110 * 0111 * @return string 0112 */ 0113 public function getVerticalRight() 0114 { 0115 return $this->_uniChar(0x251C); 0116 } 0117 0118 /** 0119 * Defined by Zend_Text_Table_Decorator_Interface 0120 * 0121 * @return string 0122 */ 0123 public function getVerticalLeft() 0124 { 0125 return $this->_uniChar(0x2524); 0126 } 0127 0128 /** 0129 * Defined by Zend_Text_Table_Decorator_Interface 0130 * 0131 * @return string 0132 */ 0133 public function getHorizontalDown() 0134 { 0135 return $this->_uniChar(0x252C); 0136 } 0137 0138 /** 0139 * Defined by Zend_Text_Table_Decorator_Interface 0140 * 0141 * @return string 0142 */ 0143 public function getHorizontalUp() 0144 { 0145 return $this->_uniChar(0x2534); 0146 } 0147 0148 /** 0149 * Convert am unicode character code to a character 0150 * 0151 * @param integer $code 0152 * @return string|false 0153 */ 0154 protected function _uniChar($code) 0155 { 0156 if ($code <= 0x7F) { 0157 $char = chr($code); 0158 } else if ($code <= 0x7FF) { 0159 $char = chr(0xC0 | $code >> 6) 0160 . chr(0x80 | $code & 0x3F); 0161 } else if ($code <= 0xFFFF) { 0162 $char = chr(0xE0 | $code >> 12) 0163 . chr(0x80 | $code >> 6 & 0x3F) 0164 . chr(0x80 | $code & 0x3F); 0165 } else if ($code <= 0x10FFFF) { 0166 $char = chr(0xF0 | $code >> 18) 0167 . chr(0x80 | $code >> 12 & 0x3F) 0168 . chr(0x80 | $code >> 6 & 0x3F) 0169 . chr(0x80 | $code & 0x3F); 0170 } else { 0171 return false; 0172 } 0173 0174 return $char; 0175 } 0176 }