original_string: protected function attemptConversion($string, $sourceEncoding, $targetEncoding)
      {
          // if source and target encodings are the same, it's a no-op
          if ($sourceEncoding === $targetEncoding) {
              return $string;
          }
  
          $convertedString = null;
  
          if ($this->canUseIconv()) {
              $convertedString = $this->globalFunctionsHelper->iconv($string, $sourceEncoding, $targetEncoding);
          } else if ($this->canUseMbString()) {
              $convertedString = $this->globalFunctionsHelper->mb_convert_encoding($string, $sourceEncoding, $targetEncoding);
          } else {
              throw new EncodingConversionException("The conversion from $sourceEncoding to $targetEncoding is not supported. Please install \"iconv\" or \"PHP Intl\".");
          }
  
          if ($convertedString === false) {
              throw new EncodingConversionException("The conversion from $sourceEncoding to $targetEncoding failed.");
          }
  
          return $convertedString;
      }
code: protected function attemptConversion($string, $sourceEncoding, $targetEncoding)
      {
          // if source and target encodings are the same, it's a no-op
          if ($sourceEncoding === $targetEncoding) {
              return $string;
          }
  
          $convertedString = null;
  
          if ($this->canUseIconv()) {
              $convertedString = $this->globalFunctionsHelper->iconv($string, $sourceEncoding, $targetEncoding);
          } else if ($this->canUseMbString()) {
              $convertedString = $this->globalFunctionsHelper->mb_convert_encoding($string, $sourceEncoding, $targetEncoding);
          } else {
              throw new EncodingConversionException("The conversion from $sourceEncoding to $targetEncoding is not supported. Please install \"iconv\" or \"PHP Intl\".");
          }
  
          if ($convertedString === false) {
              throw new EncodingConversionException("The conversion from $sourceEncoding to $targetEncoding failed.");
          }
  
          return $convertedString;
      }
code_tokens: protected function attemptConversion ( $ string , $ sourceEncoding , $ targetEncoding ) { // if source and target encodings are the same, it's a no-op if ( $ sourceEncoding === $ targetEncoding ) { return $ string ; } $ convertedString = null ; if ( $ this -> canUseIconv ( ) ) { $ convertedString = $ this -> globalFunctionsHelper -> iconv ( $ string , $ sourceEncoding , $ targetEncoding ) ; } else if ( $ this -> canUseMbString ( ) ) { $ convertedString = $ this -> globalFunctionsHelper -> mb_convert_encoding ( $ string , $ sourceEncoding , $ targetEncoding ) ; } else { throw new EncodingConversionException ( "The conversion from $sourceEncoding to $targetEncoding is not supported. Please install \"iconv\" or \"PHP Intl\"." ) ; } if ( $ convertedString === false ) { throw new EncodingConversionException ( "The conversion from $sourceEncoding to $targetEncoding failed." ) ; } return $ convertedString ; }
docstring: Attempts to convert the given string to the given encoding.
  Depending on what is installed on the server, we will try to iconv or mbstring.
  
  @param string $string string to be converted
  @param string $sourceEncoding The encoding used to encode the source string
  @param string $targetEncoding The encoding the string should be re-encoded into
  @return string The converted string, encoded with the given encoding
  @throws \Box\Spout\Common\Exception\EncodingConversionException If conversion is not supported or if the conversion failed
docstring_tokens: Attempts to convert the given string to the given encoding . Depending on what is installed on the server we will try to iconv or mbstring .