Search code examples
androidkotlinokhttp

OkHttp: Lack of possibility to change charset for post request


I need to post form data with some rare charset, and...

Instead of addFormDataPart(name, value@rareCharset), I figued out from sources that it can be apply { addPart(MultipartBody.Part.createFormData(name, null, [email protected]("text/plain; charset=rareCharset".toMediaType()))) }. BUT there is nothig I can use instead of addFormDataPart(name, filename@RareCharset, data). There is deeply hardcoded "utf-8" as I can see.


Solution

  • You could copy the MultipartBody class into your project. It’s self-contained and you can do whatever you like with exotic charsets.