TF-2602 Set charset for attachment with mimeType=text/plain when sent email on web
This commit is contained in:
@@ -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.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user