utf8_encode transforms the encoding of a string from ISO 8859-1 to UTF-8. It tries to do that even if the string is already UTF-8.
How do I encode a string to UTF-8 in Node?
What does UTF-8 stand for?
UTF-8 (UCS Transformation Format 8) is the World Wide Web’s most common character encoding. Each character is represented by one to four bytes. UTF-8 is backward-compatible with ASCII and can represent any standard Unicode character.
How do I decode and encode in Node JS?
This can be done using the Buffer. from() method that accepts the string to be converted and the current encoding of the string. This encoding can be specified as “utf8”. The converted bytes can then be returned as a base64 using the toString() method.