Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Strange behavior when using TextDecoder #9941

Copy link
Copy link
Open
@abdallahkadour

Description

@abdallahkadour
Issue body actions

Issue Description

The textDecoder has strange behavior when working with cbor data.
In node, it is working as expected but in nativescript the TextDecoder returns a strange format:

const buffer = ArrayBuffer.isView(input) ? input.buffer : input;

More info:

Issue in node-cbor

Reproduction

https://github.com/abdallahkadour/cbor-node-ns-example

A code snippet will be executed in the app component.

clone and

$ns run ios

It executes the code:

import * as process from "process";
global.process = process;
import * as prereqs from "cbor-rn-prereqs";
import * as cbor from "cbor";

    let object = {
      "1": "DE",
      "6": 1622316073,
      "4": 1643356073,
    };

    console.log(
      "The object ",
      object,
      " Will be encoded and decoded using cbor"
    );

    let encoded = cbor.encode(object);

    console.log("The encode object hex ", encoded.toString("hex"));
    console.log("The encode object ", encoded);

    let decoded = cbor.decode(encoded);
    let decodedString = JSON.stringify(decoded);
    console.log("the decoded string", decodedString);

Relevant log output (if applicable)

The decoded object should be `{
      "1": "DE",
      "6": 1622316073,
      "4": 1643356073,
    };`

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.