Skip to content

How to determinate whether a value is string or binary #39

@darkl

Description

@darkl

Hi @yfakariya
From my understanding, MsgPack 5 supports distinction between string values to binary values.

How can I determinate what have I read from the stream?

I tried this code

MemoryStream stream = new MemoryStream();
Packer packer = Packer.Create(stream);
packer.PackBinary(new byte[16]);
stream.Position = 0;

Unpacker unpacker = Unpacker.Create(stream);
unpacker.Read();
Type type = unpacker.LastReadData.UnderlyingType; // string?

But it tells me a string was written.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions