src/PhpConsole/Connector.php
protected function convertEncoding(&$string, $toEncoding, $fromEncoding) {
		if($string && is_string($string) && $toEncoding != $fromEncoding) {
			static $isMbString;
			if($isMbString === null) {
				$isMbString = extension_loaded('mbstring');
			}
			if($isMbString) {
				$string = @mb_convert_encoding($string, $toEncoding, $fromEncoding) ? : $string;
			}
			else {
				$string = @iconv($fromEncoding, $toEncoding . '//IGNORE', $string) ? : $string;
			}
			if(!$string && $toEncoding == 'UTF-8') {
				$string = utf8_encode($string);
			}
		}
	}
protected function convertEncoding(&$string, $toEncoding, $fromEncoding) {
		if($string && is_string($string) && $toEncoding != $fromEncoding) {
			static $isMbString;
			if($isMbString === null) {
				$isMbString = extension_loaded('mbstring');
			}
			if($isMbString) {
				$string = @mb_convert_encoding($string, $toEncoding, $fromEncoding) ? : $string;
			}
			else {
				$string = @iconv($fromEncoding, $toEncoding . '//IGNORE', $string) ? : $string;
			}
			if(!$string && $toEncoding == 'UTF-8') {
				$string = utf8_encode($string);
			}
		}
	}
protected function convertEncoding ( & $ string , $ toEncoding , $ fromEncoding ) { if ( $ string && is_string ( $ string ) && $ toEncoding != $ fromEncoding ) { static $ isMbString ; if ( $ isMbString === null ) { $ isMbString = extension_loaded ( 'mbstring' ) ; } if ( $ isMbString ) { $ string = @ mb_convert_encoding ( $ string , $ toEncoding , $ fromEncoding ) ? : $ string ; } else { $ string = @ iconv ( $ fromEncoding , $ toEncoding . '//IGNORE' , $ string ) ? : $ string ; } if ( ! $ string && $ toEncoding == 'UTF-8' ) { $ string = utf8_encode ( $ string ) ; } } }
Convert string encoding
@param string $string
@param string $toEncoding
@param string|null $fromEncoding
@throws \Exception
Convert string encoding