Malformed UTF-8 characters, possibly incorrectly encoded

when i generate foreign language data (ie. characters that have accented letters, etc.), they import into the database just fine. but when accessed via PHP or Python, i get this lovely error:

Malformed UTF-8 characters, possibly incorrectly encoded

which seems odd to me, the characters are readable from the SQL side of things and queries run there have no issue. but when any queries are run in the browser via PHP, for example, it errors out on those fields that contain the Malformed UTF-8 characters and they are ALL accented ones. the database itself is UTF-8_unicode_ci, which shouldn’t cause any issues AFAIK, but i’m getting errors nonetheless. and i’m stumped on how to solve this.