I'm using ruby 2.2.2, and Emoji But for some reason some icons don't dispayed For example (from http://apps.timwhitlock.info/emoji/tables/unicode):
Unicode: U+26F5
Bytes (UTF-8): \xE2\x9B\xB5
Description: SAILBOAT
Maybe someone know, how I can fix it?
I know that it works in Java, JS, JRuby, and the problem is:
https://en.wikipedia.org/wiki/UTF-8#Invalid_code_points
Thanks!
// for JS // for converting unicode code points and code pairs to their respective characters convert = function(unicode) { if(unicode.indexOf("-") > -1) { var parts = []; var s = unicode.split('-'); for(var i = 0; i < s.length; i++) { var part = parseInt(s[i], 16); if (part >= 0x10000 && part <= 0x10FFFF) { var hi = Math.floor((part - 0x10000) / 0x400) + 0xD800; var lo = ((part - 0x10000) % 0x400) + 0xDC00; part = (String.fromCharCode(hi) + String.fromCharCode(lo)); } else { part = String.fromCharCode(part); } parts.push(part); } return parts.join(''); } else { var s = parseInt(unicode, 16); if (s >= 0x10000 && s <= 0x10FFFF) { var hi = Math.floor((s - 0x10000) / 0x400) + 0xD800; var lo = ((s - 0x10000) % 0x400) + 0xDC00; return (String.fromCharCode(hi) + String.fromCharCode(lo)); } else { return String.fromCharCode(s); } } };
This works for JavaScript, but if JS output is returned to ruby it doesn't work.