本文整理汇总了PHP中iconv_get_encoding函数的典型用法代码示例。如果您正苦于以下问题:PHP iconv_get_encoding函数的具体用法?PHP iconv_get_encoding怎么用?PHP iconv_get_encoding使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了iconv_get_encoding函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEncoding
public function getEncoding(string $type = 'input') : string
{
if (!in_array($type, $this->inputs)) {
throw new InvalidArgumentException('Error', 'invalidInput', $type);
}
return iconv_get_encoding($type . '_encoding');
}
示例2: getEncoding
public function getEncoding($type = 'input')
{
if (!is_string($type) || empty($type)) {
return Error::set(lang('Error', 'stringParameter', '1.(type)'));
}
return iconv_get_encoding($type . '_encoding');
}
示例3: _purifyValue
protected function _purifyValue($val)
{
if ($val == $this->_example) {
$val = null;
} else {
static $purifier = null;
if ($this->_prevent_xss) {
if (!empty($val)) {
if ($purifier == null && class_exists('HTMLPurifier')) {
if (iconv_get_encoding("internal_encoding") != "UTF-8") {
$config = HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', iconv_get_encoding("internal_encoding"));
// replace with your encoding
$purifier = new HTMLPurifier($config);
} else {
$purifier = new HTMLPurifier();
}
}
if ($purifier != null) {
$val = $purifier->purify($val);
}
}
}
}
return $val;
}
示例4: getOutputEncoding
/**
* @return string
*/
public static function getOutputEncoding()
{
if (self::versionGreaterOrEquals56()) {
return ini_get('output_encoding');
}
return iconv_get_encoding('output_encoding');
}
示例5: getInternalEncoding
/**
* Gets the current internal encoding.
*
* @return string The encoding "name".
* @throws EncodingDetectionException If the detection fails.
*/
public static function getInternalEncoding()
{
$encoding = iconv_get_encoding(static::ICONV_INTERNAL_ENCODING_FLAG);
if (false === $encoding) {
throw EncodingDetectionException::forCurrentSystem();
}
return $encoding;
}
示例6: mb_internal_encoding
function mb_internal_encoding($enc = FALSE)
{
if (function_exists('iconv_set_encoding')) {
if ($enc) {
iconv_set_encoding('internal_encoding', $enc);
}
return iconv_get_encoding('internal_encoding');
}
return '';
}
示例7: setEncoding
public function setEncoding($encoding = null)
{
if ($encoding !== null) {
$orig = iconv_get_encoding('internal_encoding');
$result = iconv_set_encoding('internal_encoding', $encoding);
if (!$result) {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception('Given encoding not supported on this OS!');
}
iconv_set_encoding('internal_encoding', $orig);
}
$this->_encoding = $encoding;
return $this;
}
示例8: initIconv
/**
* init iconv
*/
protected static function initIconv()
{
if (extension_loaded('iconv')) {
if ('UTF-8' !== strtoupper(iconv_get_encoding('input_encoding'))) {
iconv_set_encoding('input_encoding', 'UTF-8');
}
if ('UTF-8' !== strtoupper(iconv_get_encoding('internal_encoding'))) {
iconv_set_encoding('internal_encoding', 'UTF-8');
}
if ('UTF-8' !== strtoupper(iconv_get_encoding('output_encoding'))) {
iconv_set_encoding('output_encoding', 'UTF-8');
}
} elseif (!defined('ICONV_IMPL')) {
require __DIR__ . '/bootup/iconv.php';
}
}
示例9: initIconv
public static function initIconv()
{
if (extension_loaded('iconv')) {
if ('UTF-8' !== strtoupper(iconv_get_encoding('input_encoding'))) {
iconv_set_encoding('input_encoding', 'UTF-8');
}
if ('UTF-8' !== strtoupper(iconv_get_encoding('internal_encoding'))) {
iconv_set_encoding('internal_encoding', 'UTF-8');
}
if ('UTF-8' !== strtoupper(iconv_get_encoding('output_encoding'))) {
iconv_set_encoding('output_encoding', 'UTF-8');
}
} elseif (!function_exists('iconv')) {
require __DIR__ . '/Bootup/iconv.php';
}
}
示例10: loadResources
public function loadResources($language_iso_code, __ActionIdentity $action_identity = null)
{
$language_file = $this->getLanguageFile($language_iso_code, $action_identity);
$return_value = array();
if (is_file($language_file) && is_readable($language_file)) {
$resources = parse_ini_file($language_file, false);
foreach ($resources as $key => $value) {
if ($this->_encoding != null) {
$value = iconv($this->_encoding, iconv_get_encoding("internal_encoding"), $value);
}
$resource = $this->_createResource($key, $value);
$return_value[$key] = $resource;
unset($resource);
}
}
return $return_value;
}
示例11: setEncoding
public function setEncoding($encoding = null)
{
if ($encoding !== null) {
$orig = iconv_get_encoding('internal_encoding');
if (PHP_VERSION_ID < 50600) {
$result = iconv_set_encoding('internal_encoding', $encoding);
} else {
$result = ini_set('default_charset', $encoding);
}
if (!$result) {
throw new Exception('Given encoding not supported on this OS!');
}
if (PHP_VERSION_ID < 50600) {
iconv_set_encoding('internal_encoding', $orig);
} else {
ini_set('default_charset', $orig);
}
}
$this->_encoding = $encoding;
return $this;
}
示例12: initIconv
static function initIconv()
{
if (extension_loaded('iconv')) {
if ('UTF-8' !== iconv_get_encoding('input_encoding')) {
iconv_set_encoding('input_encoding', 'UTF-8');
ini_set('iconv.input_encoding', 'UTF-8');
}
if ('UTF-8' !== iconv_get_encoding('internal_encoding')) {
iconv_set_encoding('internal_encoding', 'UTF-8');
ini_set('iconv.internal_encoding', 'UTF-8');
}
if ('UTF-8' !== iconv_get_encoding('output_encoding')) {
iconv_set_encoding('output_encoding', 'UTF-8');
ini_set('iconv.output_encoding', 'UTF-8');
}
} else {
if (!defined('ICONV_IMPL')) {
require __DIR__ . '/Bootup/iconv.php';
}
}
}
示例13: setEncoding
/**
* Sets a new encoding to use
*
* @param string $encoding
* @return \Zend\Validator\StringLength
*/
public function setEncoding($encoding = null)
{
if ($encoding !== null) {
$orig = iconv_get_encoding('internal_encoding');
$result = iconv_set_encoding('internal_encoding', $encoding);
if (!$result) {
throw new Exception\InvalidArgumentException('Given encoding not supported on this OS!');
}
iconv_set_encoding('internal_encoding', $orig);
}
$this->_encoding = $encoding;
return $this;
}
示例14: _api_iconv_set_encoding
/**
* Sets specified internal encoding configuration variables within the PHP iconv extension.
* @param string $type The parameter $type could be: 'iconv_internal_encoding', 'iconv_input_encoding', or 'iconv_output_encoding'.
* @param string $encoding (optional) The desired encoding to be set.
* @return bool Returns TRUE on success, FALSE on error.
* Note: This function is used in the global initialization script for setting these three internal encodings to the platform's character set.
* @link http://php.net/manual/en/function.iconv-set-encoding
*/
function _api_iconv_set_encoding($type, $encoding = null)
{
static $iconv_internal_encoding = null;
static $iconv_input_encoding = null;
static $iconv_output_encoding = null;
if (!ICONV_INSTALLED) {
return false;
}
switch ($type) {
case 'iconv_internal_encoding':
if (empty($encoding)) {
if (is_null($iconv_internal_encoding)) {
$iconv_internal_encoding = @iconv_get_encoding($type);
}
return $iconv_internal_encoding;
}
if (_api_iconv_supports($encoding)) {
if (@iconv_set_encoding($type, $encoding)) {
$iconv_internal_encoding = $encoding;
return true;
}
return false;
}
return false;
case 'iconv_input_encoding':
if (empty($encoding)) {
if (is_null($iconv_input_encoding)) {
$iconv_input_encoding = @iconv_get_encoding($type);
}
return $iconv_input_encoding;
}
if (_api_iconv_supports($encoding)) {
if (@iconv_set_encoding($type, $encoding)) {
$iconv_input_encoding = $encoding;
return true;
}
return false;
}
return false;
case 'iconv_output_encoding':
if (empty($encoding)) {
if (is_null($iconv_output_encoding)) {
$iconv_output_encoding = @iconv_get_encoding($type);
}
return $iconv_output_encoding;
}
if (_api_iconv_supports($encoding)) {
if (@iconv_set_encoding($type, $encoding)) {
$iconv_output_encoding = $encoding;
return true;
}
return false;
}
return false;
}
return false;
}
示例15: testDecodeString
public function testDecodeString()
{
$is = Mime\Decode::decodeQuotedPrintable('=?UTF-8?Q?"Peter M=C3=BCller"?= <peter-mueller@example.com>');
$should = iconv('UTF-8', iconv_get_encoding('internal_encoding'), '"Peter Müller" <peter-mueller@example.com>');
$this->assertEquals($is, $should);
}