Text conversion Base64->utf-8

Hello.
I recive data in Base64 and need decode to utf-8.
I used a converter, but it didn't help...
Does anyone know how to do this?

[
    {
        "id": "15e0f3e34971d2cc",
        "type": "function",
        "z": "73a54536c2c8a28a",
        "name": "",
        "func": "const base64 = '0LPRgNGD0LTQvdGW';\nconst buff = Buffer.from(base64, 'base64');\nconst str = buff.toString('utf-8');\nconsole.log(str);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 380,
        "y": 3560,
        "wires": [
            [
                "80fd16e40118a0a7"
            ]
        ]
    },
    {
        "id": "80fd16e40118a0a7",
        "type": "debug",
        "z": "73a54536c2c8a28a",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 550,
        "y": 3560,
        "wires": []
    },
    {
        "id": "202e3eed2b1a9439",
        "type": "inject",
        "z": "73a54536c2c8a28a",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0LPRgNGD0LTQvdGW",
        "payloadType": "str",
        "x": 180,
        "y": 3560,
        "wires": [
            [
                "15e0f3e34971d2cc"
            ]
        ]
    }
]

What do you get when you convert 0LPRgNGD0LTQvdGW with your flow?
What do you expect 0LPRgNGD0LTQvdGW to be?

I get 0LPRgNGD0LTQvdGW
should be грудні
This word is in Ukrainian

Thats what I get.

image

So it is something in your flow - specifically the function.

Try...

const base64 = '0LPRgNGD0LTQvdGW';
const buff = Buffer.from(base64, 'base64');
const str = buff.toString('utf-8');
msg.payload = str // <<< you missed this line
return msg;

thanks it worked

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