File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change
1
+ import "package:msgpack/msgpack.dart" ;
2
+
3
+ import "dart:io" ;
4
+ import "dart:convert" ;
5
+ import "dart:typed_data" ;
6
+
7
+ import "package:crypto/crypto.dart" ;
8
+
9
+ main () async {
10
+ var string = await stdin.transform (const Utf8Decoder ()).join ();
11
+ var hexBytes = string.split (" " ).where ((s) => s.trim ().isNotEmpty).map ((s) {
12
+ return int .parse (s, radix: 16 );
13
+ }).toList ();
14
+
15
+ var data = unpack (hexBytes);
16
+ var encoder = new JsonEncoder ((e) {
17
+ if (e is Float ) {
18
+ return e.value;
19
+ } else if (e is ByteData ) {
20
+ return CryptoUtils .bytesToBase64 (
21
+ e.buffer.asUint8List (e.offsetInBytes, e.lengthInBytes)
22
+ );
23
+ } else {
24
+ return e;
25
+ }
26
+ });
27
+
28
+ print (encoder.convert (data));
29
+ }
Original file line number Diff line number Diff line change @@ -142,7 +142,7 @@ class MsgPackBuffer implements PackBuffer {
142
142
for (var i = 0 ; i < bufferCount; i++ ) {
143
143
Uint8List buff = _buffers[i];
144
144
145
- for (var x = 0 ; x < buff.lengthInBytes; x++ ) {
145
+ for (var x = buff.offsetInBytes ; x < buff.lengthInBytes; x++ ) {
146
146
out[off] = buff[x];
147
147
off++ ;
148
148
}
You can’t perform that action at this time.
0 commit comments