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;
    }