# Help converting buffer to string encoding not matching debug output

**URL:** <https://discourse.nodered.org/t/help-converting-buffer-to-string-encoding-not-matching-debug-output/78388>\
**Category:** General\
**Tags:** function-node\
**Created:** [12 May 2023 16:15 UTC](https://discourse.nodered.org/t/help-converting-buffer-to-string-encoding-not-matching-debug-output/78388 "2023-05-12T16:15:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnnyPicnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnnypicnic/32/34787_2.png) [@JohnnyPicnic](https://discourse.nodered.org/u/JohnnyPicnic)\
**Post date:** [12 May 2023 16:15 UTC](https://discourse.nodered.org/t/help-converting-buffer-to-string-encoding-not-matching-debug-output/78388/1 "2023-05-12T16:15:51Z")

</div>

I can't seem to get a buffer to convert into a string like the debug node is showing.  
My buffer is:

```auto
[64,242,199,249,162,6]

```

The desired string is:

```auto
@òÇù¢

```

The string i'm getting is:

```auto
@rGy"

```

The buffer for the string I'm getting is:

```auto
[64,86,69,121,34,6]

```

I'm using msg.payload = msg.payload.toString("ascii") to convert the buffer and I have tried all the different encoding option I could find. It seems like only certain characters are converting properly.  
 ![2023-05-12_10-13-39](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/9/a95ee19b6fe32153ba8661e07399169c2b5e79b8.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [12 May 2023 16:42 UTC](https://discourse.nodered.org/t/help-converting-buffer-to-string-encoding-not-matching-debug-output/78388/2 "2023-05-12T16:42:29Z")

</div>

try

```auto
msg.payload = String.fromCharCode(...msg.payload);

```

---

<div class="post-metadata">

**Author:** ![JohnnyPicnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnnypicnic/32/34787_2.png) [@JohnnyPicnic](https://discourse.nodered.org/u/JohnnyPicnic)\
**Post date:** [12 May 2023 16:59 UTC](https://discourse.nodered.org/t/help-converting-buffer-to-string-encoding-not-matching-debug-output/78388/3 "2023-05-12T16:59:01Z")

</div>

Thank you!

---

<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:** [26 May 2023 16:59 UTC](https://discourse.nodered.org/t/help-converting-buffer-to-string-encoding-not-matching-debug-output/78388/4 "2023-05-26T16:59:25Z")

</div>

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