Hey guys, is there any specific node or function to convert text to unicode and then decode it to the original text?
It looks like your topic is missing some important information. Could you provide the following if applicable.
- n8n version:
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system:
You could use a code node for this and simple JavaScript. If your input has a text
property this could be the code to convert it to unicode:
const items = $input.all();
const unicodeItems = items.map((item) => {
const text = item.json.text;
const unicodeText = text
.split("")
.map((char) => "\\u" + char.charCodeAt(0).toString(16))
.join("");
item.json.unicodeText = unicodeText;
return item;
});
return unicodeItems;
and to decode it back to text (given the unicodeText
property of your input items):
const items = $input.all();
const updatedItems = items.map((item) => {
item.json.unicodeText = item.json.unicodeText
.split("\\u")
.slice(1)
.map((hex) => String.fromCharCode(parseInt(hex, 16)))
.join("");
return item;
});
return updatedItems;
Hope that helps!
1 Like
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.