java - How to post cyrillic symbols in WINDOWS-1251 with OkHttp library? -


i'm trying post field cyrillic symbols in windows-1251 in android application. have:

requestbody formbody = new formencodingbuilder()     .add("login", user)     .add("pass", password)     .build();  request request = new request.builder()     .addheader("user-agent", user_agent)     .addheader("connection", "keep-alive")     .url(url)     .post(formbody)     .build();  okhttpclient client = new okhttpclient(); response response = client.newcall(request).execute(); if (!response.issuccessful()) throw new ioexception("unexpected code " + response); string responsebody = response.body().string(); 

what need add able use cp1251 encoding fields?

i recommend try include in request content-type header, along proper charset:

.addheader("content-type", "text/plain; charset=windows-1251") 

see rfc2068 14.18.


Comments