Sending text and file. Such trouble that the server gets enter image description here

sign? instead of Russian words. I take the text from edittext:

name = nameFF.getText().toString().trim(); naselpunkt = naspunkt.getText().toString().trim(); street = ulica.getText().toString().trim(); house = dom.getText().toString().trim(); e_mail = email.getText().toString().trim(); message = mesages.getText().toString().trim(); 

I found this way on the network: Question marks were sent this way:

  MultipartEntity entity = new MultipartEntity(); 

Changed to this option but nothing has changed.

  MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE,null, Charset.forName("UTF-8")); 

So add:

 entity.addPart(KEY_NAME, new StringBody(name)); entity.addPart(KEY_NASELPUNKT, new StringBody(naselpunkt)); entity.addPart(KEY_STREET, new StringBody(street)); entity.addPart(KEY_DOM, new StringBody(house)); entity.addPart(KEY_EMAIL, new StringBody(e_mail)); entity.addPart(KEY_MESAGES, new StringBody(message)); 

    2 answers 2

    Solved the problem in a banal way:

      Charset chars = Charset.forName("UTF-8"); entity.addPart(KEY_NAME, new StringBody(name , chars)); 

      So you need to send so that there are no question marks.

       MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addBinaryBody("company", yourKirillicString.getBytes()) builder.build(); 
      • uh something is wrong - upward
      • @upward MultipartEntity deprecated, instead you need to use MultipartEntityBuilder - georgehardcore