From f02d02155a56725b9ef4e336baa6df40e41cbc68 Mon Sep 17 00:00:00 2001 From: itismadness Date: Mon, 12 Feb 2024 23:58:41 +0000 Subject: [PATCH] Mark ext-iconv as required dependency --- composer.json | 8 +++++--- composer.lock | 3 ++- src/Util.php | 4 ++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 5fd960b..b8900c5 100644 --- a/composer.json +++ b/composer.json @@ -17,10 +17,11 @@ }, "require": { "php": "^8.1", + "ext-iconv": "*", "ext-mbstring": "*", "symfony/console": "^6.0|^7.0", - "symfony/yaml": "^6.0|^7.0", - "symfony/process": "^6.0|^7.0" + "symfony/process": "^6.0|^7.0", + "symfony/yaml": "^6.0|^7.0" }, "bin": ["bin/logchecker"], "require-dev": { @@ -45,6 +46,7 @@ "config": { "platform": { "php": "8.1" - } + }, + "sort-packages": true } } diff --git a/composer.lock b/composer.lock index 592446a..1ab89d8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e4d60c26c156775fe28702c92cf76037", + "content-hash": "7f154ad99b1d7d4d57ba32adf8ecaaa9", "packages": [ { "name": "psr/container", @@ -2618,6 +2618,7 @@ "prefer-lowest": false, "platform": { "php": "^8.1", + "ext-iconv": "*", "ext-mbstring": "*" }, "platform-dev": [], diff --git a/src/Util.php b/src/Util.php index 32ca876..47e2fe2 100644 --- a/src/Util.php +++ b/src/Util.php @@ -39,6 +39,10 @@ class Util } elseif ($chardet !== null) { $results = $chardet->analyze($logPath); if ($results['charset'] !== 'utf-8' && $results['confidence'] > 0.7) { + // ideally we'd be able to use mb_convert_encoding as it has more widespread + // support vs iconv, but it does not support as many encodings as iconv, such + // as Windows-1250 (along with others) which is a common encoding for range logs + // coming from rutracker // $log = mb_convert_encoding($log, 'UTF-8', $results['charset']); $tmp = @iconv($results['charset'], 'UTF-8', $log);