Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @param \Kdyby\Curl\CurlWrapper $curl
- * @return string
- */
- public static function convertEncoding(CurlWrapper $curl)
- {
- if (Strings::checkEncoding($response = $curl->response)) {
- return Strings::normalize($response);
- }
- if ($charset = static::charsetFromContentType($curl->info['content_type'])) {
- $response = @iconv($charset, 'UTF-8', $response);
- } else {
- if ($contentType = Strings::match($response, '~<(?P<el>meta[^>]+Content-Type[^>]+)>~i')) {
- foreach (Nette\Utils\Html::el($contentType['el'])->attrs as $attr => $value) {
- if (strtolower($attr) !== 'content') {
- continue;
- }
- if ($charset = static::charsetFromContentType($value)) {
- $response = @iconv($charset, 'UTF-8', $response);
- $response = static::fixContentTypeMeta($response);
- break;
- }
- }
- }
- }
- return Strings::normalize($response);
- }
Advertisement
Add Comment
Please, Sign In to add comment