New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Line emojis unicode in LINE API ? #179

Closed
rupam-debnath opened this Issue Jan 29, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@rupam-debnath
Copy link

rupam-debnath commented Jan 29, 2018

let's say I want to use this emoticon 0x100078, how to do that in JAVA?
Referring this doc on Line emojis, I am setting up emojis as responses to certain Line messages.
https://developers.line.me/media/messaging-api/emoji-list.pdf

In order to send a mixed text and emoji response, how should I convert the 0x100078 emoji code so that it is rendered properly on the Line chat interface?

@kazuki-ma

This comment has been minimized.

Copy link
Contributor

kazuki-ma commented Jan 29, 2018

Sorry, it isn't clear now.

0x100078 is unicode codepoint of 'surrogate'.

There are no simple way to write like \u0123 but you can select one of following

emoji = String.valueOf(Character.toChars(0x100078));
// or
emoji = new StringBuilder().appendCodePoint(0x100078).toString();
@rupam-debnath

This comment has been minimized.

Copy link

rupam-debnath commented Jan 30, 2018

hi, thank you for responding.
Your code helped a lot.
However, I need a little more help, as currently in the code that you specified, the codePoint value passed is an int value. But, in our backend the value is retrieved as a String.
On parsing it as an integer, I am encountering NumberFormatException because of the char 'x' in the string "0x100078".
Hard coding the int argument works correctly in the appendCodePoint, but the value being supplied is a String, and not an int.
Can you help?

@kazuki-ma

This comment has been minimized.

Copy link
Contributor

kazuki-ma commented Jan 30, 2018

You can use Integer#decode (ja) to convert from 0x style hex string to int.

So you can write

emoji = String.valueOf(Character.toChars(Integer.decode("0x100078")));

( general java question but welcome :-) )

@rupam-debnath

This comment has been minimized.

Copy link

rupam-debnath commented Jan 30, 2018

Works like a charm... Thanks a lot! :D

@kazuki-ma kazuki-ma closed this Jan 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment