Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Filter / AbstractUnicode.php
blob1c399c6689d1ae9159e7ffdf22e098d7271f0c8e
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Filter;
12 abstract class AbstractUnicode extends AbstractFilter
14 /**
15 * Set the input encoding for the given string
17 * @param string|null $encoding
18 * @return self
19 * @throws Exception\InvalidArgumentException
20 * @throws Exception\ExtensionNotLoadedException
22 public function setEncoding($encoding = null)
24 if ($encoding !== null) {
25 if (!function_exists('mb_strtolower')) {
26 throw new Exception\ExtensionNotLoadedException(sprintf(
27 '%s requires mbstring extension to be loaded',
28 get_class($this)
29 ));
32 $encoding = strtolower($encoding);
33 $mbEncodings = array_map('strtolower', mb_list_encodings());
34 if (!in_array($encoding, $mbEncodings)) {
35 throw new Exception\InvalidArgumentException(sprintf(
36 "Encoding '%s' is not supported by mbstring extension",
37 $encoding
38 ));
42 $this->options['encoding'] = $encoding;
43 return $this;
46 /**
47 * Returns the set encoding
49 * @return string
51 public function getEncoding()
53 if ($this->options['encoding'] === null && function_exists('mb_internal_encoding')) {
54 $this->options['encoding'] = mb_internal_encoding();
57 return $this->options['encoding'];