Skip to content

CBOR UByteArraySerializer encodes as signed bytes #3181

Description

@twyatt

Describe the bug
The CBOR UByteArraySerializer encodes as signed bytes rather than unsigned. Only tested with UByteArraySerializer but may affect other unsigned encoding.

To Reproduce

Cbor.encodeToHexString(UByteArraySerializer(), ubyteArrayOf(208u))
    .also(::println)

Expected behavior

9f18d0ff

Which cbor.me shows as:

9F       # array(*)
   18 D0 # unsigned(208)
   FF    # primitive(*)

Actual behavior

9f382fff

Which cbor.me shows as:

9F       # array(*)
   38 2F # negative(47)
   FF    # primitive(*)

Environment

  • Kotlin version: 2.3.20
  • Library version: 1.11.0
  • Kotlin platforms tested on: JVM, JS, MacOS ARM64, WASM
  • Gradle version: 9.4.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions