'How to check string is already encode or decode in utf8?

I have array of string that are encode or decoded. I found out that if I encode again it breaks the string so do not like to encode again. However, I am not sure how ti prevent or check if string is alreay encoded ?

currently using const utf8 = require("utf8")

encode string like below utf8.encode(string)

If this string Ãcole élémentaire which is already encoded Then, if I encode again by accident it turn it into ÃÂcole élémentaire



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source