TF-2602 Set charset for attachment with mimeType=text/plain when sent email on web

This commit is contained in:
dab246
2024-02-26 13:13:11 +07:00
committed by Dat H. Pham
parent 514bc578ec
commit 2739a284d8
12 changed files with 101 additions and 49 deletions
+6 -7
View File
@@ -9,7 +9,7 @@ import 'package:flutter_charset_detector/flutter_charset_detector.dart';
import 'package:path_provider/path_provider.dart';
class FileUtils {
static const String DEFAULT_CHARSET = 'UTF-8';
static const String DEFAULT_CHARSET = 'uft-8';
static const String TEXT_PLAIN_MIME_TYPE = 'text/plain';
Future<String> _getInternalStorageDirPath({
@@ -139,14 +139,13 @@ class FileUtils {
}
}
Future<String> getFileCharset(String filePath) async {
Future<String> getCharsetFromBytes(Uint8List bytes) async {
try {
final file = File(filePath);
final decodingResult = await CharsetDetector.autoDecode(file.readAsBytesSync());
logError('FileUtils::getFileCharset: FILE_CHARSET = ${decodingResult.charset}');
return decodingResult.charset;
final decodedResult = await CharsetDetector.autoDecode(bytes);
log('FileUtils::getCharsetFromBytes: FILE_CHARSET = ${decodedResult.charset}');
return decodedResult.charset;
} catch (e) {
logError('FileUtils::getFileCharset: Exception: $e');
logError('FileUtils::getCharsetFromBytes: Exception: $e');
return DEFAULT_CHARSET;
}
}
@@ -1,4 +1,4 @@
import 'dart:js' as js;
import 'package:universal_html/js.dart' as js;
/// Whether the CanvasKit renderer is being used on web.
///