I'm having problems.
I have a REST API that uses json_encode to output data as JSON. However, sometimes data gets pushed to the API that is not UTF-8 data. And so when trying to output this data, json_encode throws an exception, because it can only handle UTF-8 data.
What should I do? Can I somehow force every incoming data to be UTF8? This seems to be hard, because I have no information what encoding the data is sent in.
Or should I try to run json_encode on the incoming data and if it can not encode return an error?
EDIT: I forgot to mention that this is a REST API. So I get POST requests to my API with lots of fields and values.