Last active
April 15, 2016 02:33
-
-
Save beefy/a2334905eed3bf623b68642cc13899dc to your computer and use it in GitHub Desktop.
encoding Unicode (including emojis) for web server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String[] msg_chars = new String[msg_text.length()]; | |
for(int i=0; i < msg_text.length(); i++) { | |
msg_chars[i] = "\\" +String.valueOf(String.format("\\u%04x", (int) msg_text.charAt(i))); | |
} | |
msg_text = "" | |
for(int i=0; i < msg_chars.length; i++) { | |
msg_text += msg_chars[i]; | |
} | |
try { | |
encoded_msg = URLEncoder.encode(msg_text, "UTF-8"); | |
} catch (UnsupportedEncodingException e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment