prepareDirectoryAbbyyLingvoFormat function

Future<void> prepareDirectoryAbbyyLingvoFormat(
  1. PrepareDirectoryParams params
)

Top-level function for use in compute. See DictionaryFormat for details.

Implementation

Future<void> prepareDirectoryAbbyyLingvoFormat(
    PrepareDirectoryParams params) async {
  String dictionaryFilePath =
      path.join(params.workingDirectory.path, 'dictionary.dsl');
  File originalFile = params.file;
  File newFile = File(dictionaryFilePath);

  if (params.charset.startsWith('UTF-16')) {
    final utf16CodeUnits = originalFile.readAsBytesSync().buffer.asUint16List();
    var converted = String.fromCharCodes(utf16CodeUnits);
    newFile.createSync();
    newFile.writeAsStringSync(converted);
  } else {
    originalFile.copySync(newFile.path);
  }
}