Special character conversion issues

Hi everyone,

I'm working on a tool to convert a JSON file to specific text file formatting (Facebook Archive to Day One). It's working fine, but I have issues with accentuation (French language).

For example, "\u00c3\u00a9t\u00c3\u00a9" should convert to "été" but my flow convert it to "été"

It tried to play with node-red-contrib-iconv, but without success.

Any help will be welcome.

My flow:

[{"id":"15947a802a312bf0","type":"debug","z":"6cf7250c223824e5","name":"debug raw","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":440,"wires":[]},{"id":"dce391c280522b44","type":"split","z":"6cf7250c223824e5","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":470,"y":520,"wires":[["15947a802a312bf0","6985f38d738df803"]]},{"id":"a507fc248d041d37","type":"debug","z":"6cf7250c223824e5","name":"debug 10","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":960,"y":520,"wires":[]},{"id":"6985f38d738df803","type":"function","z":"6cf7250c223824e5","name":"function 2","func":"var title = msg.payload.title;\nvar post = msg.payload.data[0].post;\nlet unix_timestamp = msg.payload.timestamp;\n\n// Create a new JavaScript Date object based on the timestamp\n// multiplied by 1000 so that the argument is in milliseconds, not seconds.\nvar d = new Date(unix_timestamp * 1000);\n \n// month as a number 0-11\nvar months = { 1: \"January\", 2: \"February\", 3: \"March\", 4: \"April\", 5: \"May\", 6: \"June\", 7: \"July\", 8: \"August\", 9: \"September\", 10: \"October\", 11: \"November\", 12: \"December\" };\nvar month = d.getMonth();\nvar month_name = months[month+1];\n\n//day as a number 1 -31\nvar day = d.getDate()  \n\n//year as a four digit number (yyyy)\nvar year = d.getFullYear() \n\n// Hours part from the timestamp\nvar hours = d.getHours();\n\n// Minutes part from the timestamp\nvar minutes = \"0\" + d.getMinutes();\n\n// Seconds part from the timestamp\nvar seconds = \"0\" + d.getSeconds();\n\nvar date = '\\tDate:\\t' + month_name + ' ' + day + ', ' + year + ' at ' + hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);\n\n// Output\nmsg.payload = date + '\\n\\n# ' + title + '\\n\\n' + post + '\\n\\n';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":520,"wires":[["06730e2a861c88bb"]]},{"id":"06730e2a861c88bb","type":"join","z":"6cf7250c223824e5","name":"","mode":"custom","build":"string","property":"msg.payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":810,"y":520,"wires":[["a507fc248d041d37"]]},{"id":"fd6e6be0ad9f9610","type":"inject","z":"6cf7250c223824e5","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\t  {\t    \"timestamp\": 1395769972,\t    \"attachments\": [\t      \t    ],\t    \"data\": [\t      {\t        \"post\": \"I'm starting to select and process my best shoots of my 1500 pictures...\\nMore pictures will come every day\"\t      },\t      {\t        \"update_timestamp\": 1395769972\t      }\t    ],\t    \"title\": \"Lucas Janin shared an album.\"\t  },\t  {\t    \"timestamp\": 1395812484,\t    \"attachments\": [\t      \t    ],\t    \"data\": [\t      {\t        \"post\": \"Fin de f\\u00c3\\u00aate au #Bequinox \\n\\nCette photo a \\u00c3\\u00a9t\\u00c3\\u00a9 prise a 7 heures du matin avant le lever du soleil. Mes mod\\u00c3\\u00a8les avaient fait la fete toute la nuit...\\n\\nL'\\u00c3\\u00a9clairage a \\u00c3\\u00a9t\\u00c3\\u00a9 r\\u00c3\\u00a9aliser via un flash Quadra Elinchrom et un Deep Octa de 1 m\\u00c3\\u00a8tre. La lumi\\u00c3\\u00a8re naturel pour d\\u00c3\\u00a9boucher les hombres...\"\t      },\t      {\t        \"update_timestamp\": 1395812484\t      }\t    ],\t    \"title\": \"Lucas Janin shared a photo.\"\t  }\t]","payloadType":"jsonata","x":310,"y":520,"wires":[["dce391c280522b44"]]}]

If you try to set it up like this with iconv:

Result:

	Date:	March 25, 2014 at 18:52:52

# Lucas Janin shared an album.

I'm starting to select and process my best shoots of my 1500 pictures...
More pictures will come every day

	Date:	March 26, 2014 at 6:41:24

# Lucas Janin shared a photo.

Fin de fête au #Bequinox 

Cette photo a été prise a 7 heures du matin avant le lever du soleil. Mes modèles avaient fait la fete toute la nuit...

L'éclairage a été réaliser via un flash Quadra Elinchrom et un Deep Octa de 1 mètre. La lumière naturel pour déboucher les hombres...


1 Like

Work perfectly! Thanks for your help!!!

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