0

When I send emojis nums icons, 1,2,3,4,5.... send correctly, But when I try send emojis icons how smile or others ... not send nothing ...

My debug show a face smile, but not send. why ? then seems to not clean the buffer, and when you rewrite, the activity is closed, but not when using numbers icons emojis.

The listener not called, when I use icons fases, but yes when I use icons numbers.

enter image description here

public void sendMessageServer()throws XMPPException{
        Message msg= new Message();
        String tim =  "            "+time;
        Chat chat = chatManager.createChat(CurrentUsernameClick+"@delive", messageListener);
        if(message_list.getText().toString()!=null && message_list.length()>0){
            String text = message_list.getText().toString();
            msg.setBody(message_list.getText().toString() +tim);
            chat.sendMessage(message_list.getText().toString() + tim);
            addNewMessage(new Messages(msg.getBody(), true));
            UserDataAccesObject.createMessage(id, id, msg.getBody(), usernameSession, CurrentUsernameClick, time);
            message_list.setText("");
        }
    }

DEBUG SHOW :

enter image description here enter image description here I send correctly numbers, but smiles face not.

http://apps.timwhitlock.info/emoji/tables/unicode

I have 2 ideas : 1 (orc) 2 (ASCII)

1 -

I think that I need recognize characters not? with library OCR not ?

in my debugger, show [?] with icons, I think that is because not recognize character correctly, or am I wrong?

2 -

Or can be ASCII ?

Taryn
  • 242,637
  • 56
  • 362
  • 405

2 Answers2

2

Try showing the hex values of the characters in your strings. You may find that the first one shows 0x0031 (DIGIT ONE) and 0x20DE (COMBINING ENCLOSING SQUARE), which are two Unicode code points that combine together to make "1⃞". The second one may show 0xD83D 0xDE03, which is UTF-16 for a single Unicode character "" (U+1F603 SMILING FACE WITH OPEN MOUTH). Next look at what actually gets written on the wire. In hex, the first one should be: 31E2839E and the second should be F09F9883, both of which are the UTF-8 encodings for their respective Unicode code points.

Several libraries have bugs dealing with characters higher than U+FFFF. It may be that you have run into one of these. If that is the case, you might see something like EDA0BDEDB883 (hex) for the smilie's output. This is invalid UTF-8, and should be rejected by a server compliant with RFC 6120.

Community
  • 1
  • 1
Joe Hildebrand
  • 10,354
  • 2
  • 38
  • 48
  • Not directly, not send nothing. I think that is method to send wrong(algoritmic), because my listview/edittext/sqlite/adapter/Toast recognize the icons (as I showed above), but not chat.sendMessage, not recognize icons, https://community.igniterealtime.org/thread/52552?tstart=0 , How I can do, to recognize icons of characters special, to send? –  May 11 '14 at 10:32
  • I tried : name = new String(message_list.getText().toString().getBytes("UTF-8"), "ISO-8859-1"); and I get : smile : "??", word = "word" , icon number 1 = "1?" –  May 11 '14 at 18:42
  • I'm going crazy trying encodings: name = new String; (message_list.getText () toString () getBytes ("ISO-8859-1"), "UTF-16"..) , Returns chinese characters, I do not know the Chinese language. –  May 11 '14 at 23:31
  • Any idea ? is very important for me –  May 12 '14 at 13:54
  • No amount of ISO-8859-1 is going to help. UTF-16 is not going to help. You likely need to file a bug with your XMPP library project (ASmack?), asking them to test with Unicode codepoints higher than U+FFFF. – Joe Hildebrand May 12 '14 at 16:23
  • Then I do? I can not do anything about the problem? send ascii and detect the listener? I can do anything? I can not waste hours and hours of work. –  May 12 '14 at 16:30
  • ISO-8859-1 only encodes characters less than U+FFFF. You are trying to encode U+1F603, which is higher than U+FFFF. You have that character in a Java string. Java strings are UTF-16 inherently, which is why it looks like you have two characters. That one codepoint, U+1F603, is in your Java string as two halves, known as a "surrogate pair" (see: http://en.wikipedia.org/wiki/UTF-16 for more info). Your XMPP library is responsible for turning UTF-16 strings into UTF-8 in order to produce valid XMPP. If it's not, you either have to fix the library or get someone else to fix it. – Joe Hildebrand May 12 '14 at 16:49
  • Alternately, just send the string ":)" and let the other side turn it into an emoticon, which is what most XMPP clients do. – Joe Hildebrand May 12 '14 at 16:51
  • not is easy ":)", my icons are set by emojicon, or how I can do ? –  May 12 '14 at 16:58
  • You could write a regular expression, but then you'd just have questions about Unicode regular expressions. Seriously, just ask your library provider for help. – Joe Hildebrand May 12 '14 at 17:06
  • I remember when I was encryptación long time ago when i was learning java. I remember one day Told Me: Everything you send "encode" and the listener hears, "ALWAYS" you can get the actual data. –  May 12 '14 at 18:00
  • Now I can send utf-16 with this word: "jaja" = ">>jaja" is a avanze, now I have to decode utf-16 Correctly, see this example http://encoder.mattiasgeniar.be/index.php –  May 12 '14 at 18:00
2

Send smile using htmlescape using apache common util lib it works for me

Jaspreet Chhabra
  • 1,431
  • 15
  • 23
  • Where I can find library of htmlescape for android ? –  May 11 '14 at 20:43
  • Works, (api 16 = @SuppressLint), but now return characters unknown for me "㈳"(smile) how I can covert this number in ? –  May 12 '14 at 22:15
  • send this character in the message and while receiving it use use StringEscapeUtils.unescapeHtml(); – Jaspreet Chhabra May 13 '14 at 10:58
  • 1 up please, if you like the answer – Jaspreet Chhabra May 13 '14 at 10:58
  • Yeah, this will work. If you don't want to take a dependency, you can run through each codepoint in the string using this answer (http://stackoverflow.com/a/1527891/8388), replacing each codepoint higher than U+FFFF with an XML escape sequence. – Joe Hildebrand May 13 '14 at 17:00