how could I override urlFormEncoded parser to use another charset in Play 2.3.x (Scala)?
I'm writing BBS software which works in Japanese environment with Play framework 2.3.x in Scala.
The problem is about charset: Client POSTs request with url encoded (aka. "percent encoded") form parameters encoded in Shift-JIS -- famous charset in Japan -- but Play decodes it as UTF-8. That is predictable because it is hardcoded in https://github.com/playframework/playframework/blob/2.3.x/framework/src/play/src/main/scala/play/api/mvc/ContentTypes.scala#L515 .
I cannot modify BBS clients' encoding because it is de-facto standard.
Thus, I must rewrite or override url encoding decoder in Play to use Shift_JIS.
There may be some solutions:
- Manually build Play from modified source code and use it.
- Intercept request and decode body as
Shift_JIS, then re-encode body asUTF-8. - Create custom parser which extends
play.api.mvc.BodyParsers.parseand use it.
Most hopeful choice I thought is 3, but I cannot create object which extends play.api.mvc.BodyParsers.parse.
So, how could I override default parser and use it (or there are other better solutions)?
Thanks.