Created
April 22, 2025 10:24
-
-
Save PlugFox/c82c6147ccac451faa55efa8b55c80ae to your computer and use it in GitHub Desktop.
Dart Utf8Decoder example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Dart Utf8Decoder example | |
* https://gist.github.com/PlugFox/c82c6147ccac451faa55efa8b55c80ae | |
* https://dartpad.dev?id=c82c6147ccac451faa55efa8b55c80ae | |
* Mike Matiunin <[email protected]>, 22 April 2025 | |
*/ | |
// ignore_for_file: avoid_print | |
import 'dart:async'; | |
import 'dart:convert'; | |
import 'dart:typed_data'; | |
void main() { | |
final bytes = Uint8List.fromList([65, 66, 67, 49, 50, 51]); | |
final stream = Stream.value(bytes); // Stream<List<int>>.value(bytes) | |
stream.transform<String>(const Utf8Decoder(allowMalformed: true)).forEach(print); | |
print(const Utf8Decoder(allowMalformed: true).convert(bytes)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment