Well there is a method to determine the charset in PHP. It's called `mb_detect_encoding.
mb_detect_encoding: http://php.net/manual/en/function.mb-detect-encoding.php
To answer your question, yes you can determine the encoding. Can you be sure? Well not really because one bit of content can be valid for multiple encoding standards. So which one would you pick?
In general I don't think you should alter the request using middlewares. Instead I would enforce the one that is posting to your application to use the correct content type. This concept is what we call "content negotiation". This is what you use in your API when you tell it to always return application/json to make sure you can handle it as well. So for example when I do a request to the server and I see my content type is application/xml the server should determine if they want/can to handle that or not. If not it should return an error/exception or.
Does this help you any further?