I am reading the file names from the file system and I want to send them as a JSON encoded array. The problem is that the files in the file system may be stored in an invalid encoding, and I need to handle this situation to omit the invalid file names before transferring them to json.dump , otherwise it will fail.
Is there a way to verify that my string (file name) contains valid utf-8 characters?
json python utf-8
troex
source share