# Dashboard 2.0 table use TextDecoder cannot display spaces

**URL:** <https://discourse.nodered.org/t/dashboard-2-0-table-use-textdecoder-cannot-display-spaces/87828>\
**Category:** Dashboard\
**Created:** [9 May 2024 08:45 UTC](https://discourse.nodered.org/t/dashboard-2-0-table-use-textdecoder-cannot-display-spaces/87828 "2024-05-09T08:45:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikelee](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikelee/32/90805_2.png) [@Mikelee](https://discourse.nodered.org/u/Mikelee)\
**Post date:** [9 May 2024 08:45 UTC](https://discourse.nodered.org/t/dashboard-2-0-table-use-textdecoder-cannot-display-spaces/87828/1 "2024-05-09T08:45:08Z")

</div>

Use example can be displayed

```auto
[
    {
        "colA": "A C. A",
        "colB": "Hello.",
        "colC": 3
    },
    {
        "colA": "B A .",
        "colB": "World. ",
        "colC": 5
    }
]

```

![螢幕擷取畫面 2024-05-09 164551](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/a/daf2a7047c2a6ce27d7cabc4f8ef141c2363fdae.png)

but using Uint8Array and TextDecoder("utf8") will display boxes in chrome and edge  
code:

```auto
let name = new Uint8Array(10).fill(' ');
const decoder = new util.TextDecoder("utf8");
const str = decoder.decode(name);
msg.topic = 'Success';
msg.payload = [{ "aaa": str,"bbb":1234 },{ "aaa":111,"bbb":123 }]
return msg;

```

![螢幕擷取畫面 2024-05-09 164028](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/6/76e0764e8a0eef6eba9c0a73545d5fb14d9b6695.png)

How can it be fixed?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [9 May 2024 09:15 UTC](https://discourse.nodered.org/t/dashboard-2-0-table-use-textdecoder-cannot-display-spaces/87828/2 "2024-05-09T09:15:54Z")

</div>

> [@Mikelee](#):
>
> `Uint8Array(10).fill(' ');`

This is not doing what you think it is. It results in :

```auto
Uint8Array(10) [
  0, 0, 0, 0, 0,
  0, 0, 0, 0, 0
]

```

What exactly are you trying to achieve?

---

<div class="post-metadata">

**Author:** ![Mikelee](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikelee/32/90805_2.png) [@Mikelee](https://discourse.nodered.org/u/Mikelee)\
**Post date:** [9 May 2024 09:36 UTC](https://discourse.nodered.org/t/dashboard-2-0-table-use-textdecoder-cannot-display-spaces/87828/3 "2024-05-09T09:36:28Z")

</div>

I need a Uint8Array to call a C++ DLL to store the returned name.

fill(' ') is just the code I tested. I don't know why 0x0 cannot display space or ignore , but it can be displayed normally in dashboard 1.0.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [9 May 2024 09:49 UTC](https://discourse.nodered.org/t/dashboard-2-0-table-use-textdecoder-cannot-display-spaces/87828/4 "2024-05-09T09:49:47Z")

</div>

> [@Mikelee](#):
>
> displayed normally in dashboard 1.0

I think it is the other way around. Dashboard 2 is correctly displaying 10 null chars. Dashboard 1 possibly trimmed null chars.

If you want to remove null chars, something like this will do it...

```auto
const cleaned = uncleaned.replace(/\0.*$/, "")

```

---

<div class="post-metadata">

**Author:** ![Mikelee](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mikelee/32/90805_2.png) [@Mikelee](https://discourse.nodered.org/u/Mikelee)\
**Post date:** [9 May 2024 10:03 UTC](https://discourse.nodered.org/t/dashboard-2-0-table-use-textdecoder-cannot-display-spaces/87828/5 "2024-05-09T10:03:33Z")

</div>

Looks like I might have misunderstood, I'll look at replace

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 May 2024 10:04 UTC](https://discourse.nodered.org/t/dashboard-2-0-table-use-textdecoder-cannot-display-spaces/87828/6 "2024-05-23T10:04:00Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
