Sha256: c68bb9f5577f5023f29d944f853278b04de24a4428d388d53e9d0e4ee41e4238

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

this.Unicode =
  unpack: (utfstring) ->
    utfstring = utfstring.replace /\r\n/g, '\n'
    string = ''

    for i in [0 .. utfstring.length]
      c = utfstring.charCodeAt(i)

      if c < 128
        string += String.fromCharCode(c)
      else if (c > 127) && (c < 2048)
        string += String.fromCharCode((c >> 6) | 192)
        string += String.fromCharCode((c & 63) | 128)
      else
        string += String.fromCharCode((c >> 12) | 224)
        string += String.fromCharCode(((c >> 6) & 63) | 128)
        string += String.fromCharCode((c & 63) | 128)

    string

  pack: (string) ->
    utfstring = ''
    i = c = c1 = c2 = 0

    while i < string.length

      c = string.charCodeAt(i)

      if c < 128
        utfstring += String.fromCharCode(c)
        i++
      else if (c > 191) && (c < 224)
        c2 = string.charCodeAt(i+1)
        utfstring += String.fromCharCode(((c & 31) << 6) | (c2 & 63))
        i += 2
      else
        c2 = string.charCodeAt(i+1)
        c3 = string.charCodeAt(i+2)
        utfstring += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63))
        i += 3

    utfstring

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
frontkit-rails-0.0.1 vendor/assets/javascripts/base64/unicode.js.coffee
frontkit-rails-0.0.0 vendor/assets/javascripts/base64/unicode.js.coffee