Commit 7e290660 authored by Ryan LeFevre's avatar Ryan LeFevre

Use iconv for proper character decoding

parent e63bf76d
{jspack} = require 'jspack'
iconv = require 'iconv-lite'
Util = require './util.coffee'
module.exports = class File
......@@ -41,10 +42,8 @@ module.exports = class File
readString: (length) -> String.fromCharCode.apply(null, @read(length)).replace /\u0000/g, ""
readUnicodeString: (length = null) ->
length or= @readInt()
@read(length * 2)
.map((c) -> Util.getUnicodeCharacter(c))
.join('')
.replace(/\u0000/g, '')
data = new Buffer(@read(length * 2))
iconv.decode(data, 'utf-16be')
readByte: -> @read(1)[0]
readBoolean: -> @readByte() isnt 0
......@@ -14,7 +14,8 @@
"coffeescript-module": "~ 0.2.1",
"pngjs": "~ 0.4.0",
"rsvp": "~ 3.0.6",
"lodash": "~ 2.4"
"lodash": "~ 2.4",
"iconv-lite": "~ 0.4.4"
},
"scripts": {
"test": "mocha test"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment