0

I am working on a project in which I am using this library https://github.com/ankushsachdeva/emojicon. I am able to see the Emoji Keyboard but when I am sending the text from Editext which contains Emoji Icons they are converted into ??

After some research I found out this solution Post UTF-8 encoded data to server loses certain characters

By using this

form = new UrlEncodedFormEntity(nameValuePairs,"UTF-8");

the problem get solved. But I have to use MultipartEntity to send images also to server.

When I set Encoding in MultiPartEntity like below:

MultiPartEntity entity = new MultiPartEntity(HttpMultipartMode.BROWSER_COMPATIBLE,
                        null, Charset.forName("UTF-8"), new MultiPartEntity.ProgressListener() {

                            @Override
                            public void transferred(long num) {
                            }
                        });

It is not working here, how can achieve the same with MultipartEntity. Please help me.

Community
  • 1
  • 1
Prithniraj Nicyone
  • 5,021
  • 13
  • 52
  • 78
  • If you are storing the message in database on your server then you can use 'utf8mb4_general_ci' collation for the message field – Ichigo Kurosaki Jan 04 '16 at 08:37
  • Also on php side while working with database you need to add mysqli_query($dbh,"SET CHARACTER SET utf8"); mysqli_query($dbh,"SET COLLATION_CONNECTION = 'utf8_general_ci'"); while making connection with database – Ichigo Kurosaki Jan 04 '16 at 08:39
  • Doing so does not changing anything, I am still getting the same issue. Please help me if you have any idea how to solve it as it is working fine with UrlEncodedFormEntity. Thanks a lot in advanced. – Prithniraj Nicyone Jan 04 '16 at 09:38
  • 1
    I have resolved this issue by doing the below change: MultiPartEntity entity = new MultiPartEntity(new MultiPartEntity.ProgressListener() { @Override public void transferred(long num) { } }); entity.addPart("body", new StringBody(mStatusBodyField.getText().toString(), Charset.forName("UTF-8"))); Added Char set to the body that contains Emojis before sending it to server. – Prithniraj Nicyone Jan 04 '16 at 10:23
  • Please use the method provided by @PrithnirajNicyone .. i.e. entity.addPart("body", new StringBody(mStatusBodyField.getText().toString(), Charset.forName("UTF-8"))); Thank you so much – Arnab Kundu Nov 22 '18 at 06:24

0 Answers0