Skip to content

Commit af36824

Browse files
committed
Allow strings to be constructed from 'bin' and 'array'
1 parent b79270e commit af36824

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Sources/MessagePack/Decoder/SingleValueDecodingContainer.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,23 @@ extension _MessagePackDecoder.SingleValueContainer: SingleValueDecodingContainer
6060
length = Int(try read(UInt16.self))
6161
case 0xdb:
6262
length = Int(try read(UInt32.self))
63+
64+
// interpret bin as string
65+
case 0xc4:
66+
length = Int(try read(UInt8.self))
67+
case 0xc5:
68+
length = Int(try read(UInt16.self))
69+
case 0xc6:
70+
length = Int(try read(UInt32.self))
71+
72+
// interpret array as string
73+
case 0x90...0x9f:
74+
length = Int(format - 0x90)
75+
case 0xdc:
76+
length = Int(try read(UInt16.self))
77+
case 0xdd:
78+
length = Int(try read(UInt32.self))
79+
6380
default:
6481
let context = DecodingError.Context(codingPath: self.codingPath, debugDescription: "Invalid format: \(format)")
6582
throw DecodingError.typeMismatch(Double.self, context)

0 commit comments

Comments
 (0)