 
 Emojis = new Mongo.Collection 'emojis',
   transform: (emoji) ->
-    
+
     # Shortcut helpers
 
     emoji.path = Emojis.basePath() + '/' + imagePath(emoji)
-    
+
     emoji.toHTML = ->
       Emojis.template(this)
 

  Emojis._ensureIndex(alias: 1)
  Emojis._ensureIndex(ascii: 1)


Emojis._basePath = '/images/emojis'


toCodePoints = (str) ->
    chars = []
    i = 0

    while i < str.length
        c1 = str.charCodeAt(i)

        if c1 >= 0xD800 and c1 < 0xDC00 and i+1 < str.length
            c2 = str.charCodeAt(i+1)
            if c2 >= 0xDC00 && c2 < 0xE000
                chars.push(0x10000 + ((c1-0xD800)<<10) + (c2-0xDC00))
                i += 2
                continue

        chars.push(c1)
        i++

