There's a few answers about this on StackOverflow, but none of them work for me.
I have mixed data coming from Google mailbox import (some are in utf-8, some are in base64) into my Node.Js app and I need to check for every string if it's in base64 or not.
Does anyone have a solution that works?
Data example
0KHQvdCw0YfQsNC70LAg0YHQvtC30LTQsNC10YLRgdGPINGA0LXRiNC10YLQutCwINC/0YDQvtGB
0YLRgNCw0L3RgdGC0LLQsCDQstC+0L7QsdGA0LDQttC10L3QuNGPLiZuYnNwOzxkaXY+PGJyPjwv
ZGl2PjxkaXY+0JfQsNGC0LXQvCDQvdCwINC90LXQtSDQvdCw0L3QuNC30YvQstCw0LXRgtGB0Y8g
0LLRi9C80YvRgdC10LsuPC9kaXY+PGRpdj48
Code to get it github.com/mscdex/node-imap but I keep only the message text, i.e.
msg.on('body', function(stream, info) {
stream.on('data', function(chunk) {
count += chunk.length;
buffer += chunk.toString('utf8');
}
}