utf_ext 0.2.3 utf_ext: ^0.2.3 copied to clipboard
A library for reading and writing text files in any major Unicode format (UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE)
How To Use the utf_ext
Package
Contents #
utf_cat.dart
- see how to read UTF files and print to terminal, similar tocat
(POSIX) ortype
(Windows)utf_conv.dart
- see how to convert files from one UTF format to another, similar toiconv
(POSIX)
Sample code #
/// This example depends on the package 'loop_visitor'
import 'package:file/file.dart';
import 'package:loop_visitor/loop_visitor.dart';
...
final data = await filterByPrefixAndToUpperCase('example.md', '-');
...
Future<List<String>> filterByPrefixAndToUpperCase(FileSystem fs, String filePath, String prefix) async {
final pileup = <String>[];
await fs.file(filePath).readUtfAsLines(pileup: pileup, onRead: (param) {
final line = param.current!;
if (!line.startsWith(prefix)) {
return VisitResult.skip;
}
param.current = line.toUpperCase();
return VisitResult.take;
});
return pileup;
}