How to use the binary.toUnicode function in binary

To help you get started, we’ve selected a few binary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github creationix / tedit / src / tree / file.js View on Github external
self.repo.loadAs("blob", self.hash, function (err, buffer) {
      if (err) throw err;
      var imageMime = imagetypes[self.name.substr(self.name.lastIndexOf(".") + 1)];
      if (imageMime) {
        self.session = {
          tiled: false,
          url: URL.createObjectURL(new Blob([buffer], {type: imageMime}))
        };
        return onSession();
      }

      var mode = modelist.getModeForPath(self.name);
      var code;

      try {
        code = binary.toUnicode(buffer);
      }
      catch (err) {
        // Data is not unicode!
        return;
      }
      self.session = ace.createEditSession(code, mode.mode);
      whitespace.detectIndentation(self.session);
      return onSession();
    });
github creationix / tedit / src / tree3.js View on Github external
var imageMime = imagetypes[getExtension(name)];
      if (imageMime) {
        doc = docPaths[path] = {
          tiled: false,
          name: name,
          url: URL.createObjectURL(new Blob([buffer], {type: imageMime}))
        };
        return loadDoc(doc);
      }

      var mode = parseInt(node.mode, 8) === modes.sym ?
        "ace/mode/text" : modelist.getModeForPath(name).mode;

      var code;
      try {
        code = binary.toUnicode(buffer);
      }
      catch (err) {
        // Data is not unicode!
        return;
      }
      doc = docPaths[path] = ace.createEditSession(code, mode);
      doc.name = name;
      whitespace.detectIndentation(doc);
      loadDoc(doc);
    });
github creationix / tedit / src / memdb.js View on Github external
defer(function () {
        var realType = (type === "text" || type === "raw") ? "blob" : type;
        if (!types[hash]) return callback();
        if (realType !== types[hash]) return callback(new TypeError("Type mismatch"));
        var result = objects[hash];
        if (type === "text") result = binary.toUnicode(result);
        else if (type !== "blob") result = encoders.normalizeAs(type, result);
        callback(null, result, hash);
      });
    }