# How can null characters in a string be ignored?

**URL:** https://discourse.nodered.org/t/how-can-null-characters-in-a-string-be-ignored/69598
**Category:** General
**Created:** [26 October 2022 06:40 UTC](https://discourse.nodered.org/t/how-can-null-characters-in-a-string-be-ignored/69598 "2022-10-26T06:40:41Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![muharremsari](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muharremsari/32/7996_2.png) [@muharremsari](https://discourse.nodered.org/u/muharremsari)
#### Post date: [26 October 2022 06:40 UTC](https://discourse.nodered.org/t/how-can-null-characters-in-a-string-be-ignored/69598/1 "2022-10-26T06:40:41Z")

</div>

I am getting a 12 character string value with a terminating character over TCP/IP. But I get a data type error in the debug message. "TypeError: The argument 'newPath' must be a string or Uint8Array without null bytes. Received 'D:registration42026659000Bx00.ravi'. What could be the reason? Regards  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/0/20bc5309adb2fb278273706cb5e37cdebb55f22c.png)

---

<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: [26 October 2022 07:04 UTC](https://discourse.nodered.org/t/how-can-null-characters-in-a-string-be-ignored/69598/2 "2022-10-26T07:04:03Z")

</div>

somewhere in your flow you append `d:\` and `???.ravi` to that string right?

It certainly looks like the `???` is `null`

Show us more info like your flow or any function code that generates that file name

---

<div class="post-metadata">

### Author: ![muharremsari](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muharremsari/32/7996_2.png) [@muharremsari](https://discourse.nodered.org/u/muharremsari)
#### Post date: [26 October 2022 08:37 UTC](https://discourse.nodered.org/t/how-can-null-characters-in-a-string-be-ignored/69598/3 "2022-10-26T08:37:27Z")

</div>

```auto
[
    {
        "id": "9503357ecd6ba5f6",
        "type": "tcp in",
        "z": "ea87b1398b776bca",
        "name": "L2 COIL ID",
        "server": "server",
        "host": "",
        "port": "2001",
        "datamode": "stream",
        "datatype": "utf8",
        "newline": "",
        "topic": "",
        "trim": false,
        "base64": false,
        "tls": "",
        "x": 140,
        "y": 380,
        "wires": [
            [
                "2ba89f82.e7991",
                "a7b2c1d1fe0681e5",
                "7a876ca634443420"
            ]
        ]
    },
    {
        "id": "7a876ca634443420",
        "type": "delay",
        "z": "ea87b1398b776bca",
        "name": "Record out time for file saving.",
        "pauseType": "delay",
        "timeout": "90",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 530,
        "y": 440,
        "wires": [
            [
                "33e06930.8b5856"
            ]
        ]
    },
    {
        "id": "33e06930.8b5856",
        "type": "fs-ops-dir",
        "z": "ea87b1398b776bca",
        "name": "",
        "path": "D:\\cam",
        "pathType": "str",
        "filter": "*.ravi",
        "filterType": "str",
        "dir": "files[0]",
        "dirType": "msg",
        "x": 740,
        "y": 440,
        "wires": [
            [
                "567fa9ed.c8bd88"
            ]
        ]
    },
    {
        "id": "567fa9ed.c8bd88",
        "type": "function",
        "z": "ea87b1398b776bca",
        "name": "",
        "func": "msg.test123 = msg.payload+\".ravi\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 890,
        "y": 440,
        "wires": [
            [
                "363603f0.472b6c"
            ]
        ]
    },
    {
        "id": "363603f0.472b6c",
        "type": "fs-ops-move",
        "z": "ea87b1398b776bca",
        "name": "",
        "sourcePath": "D:\\cam",
        "sourcePathType": "str",
        "sourceFilename": "files[0]",
        "sourceFilenameType": "msg",
        "destPath": "D:\\kayit",
        "destPathType": "str",
        "destFilename": "test123",
        "destFilenameType": "msg",
        "link": false,
        "x": 1060,
        "y": 440,
        "wires": [
            [
                "7be896a9b5f97561"
            ]
        ]
    },
    {
        "id": "7be896a9b5f97561",
        "type": "debug",
        "z": "ea87b1398b776bca",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1280,
        "y": 440,
        "wires": []
    }
]

```

---

<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: [26 October 2022 09:18 UTC](https://discourse.nodered.org/t/how-can-null-characters-in-a-string-be-ignored/69598/4 "2022-10-26T09:18:55Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/2/a28d9e729d7e4ca889eab4833c7e1e14110e0b09.png)

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [26 October 2022 12:00 UTC](https://discourse.nodered.org/t/how-can-null-characters-in-a-string-be-ignored/69598/5 "2022-10-26T12:00:13Z")

</div>

I think that you need to trim the input msg.payload string, it appears to have a spurious null on the end.

You can do that using a function node and javascript or using a change node using JSONata.

---

<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: [25 December 2022 12:00 UTC](https://discourse.nodered.org/t/how-can-null-characters-in-a-string-be-ignored/69598/6 "2022-12-25T12:00:42Z")

</div>

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