Skip to content

Instantly share code, notes, and snippets.

@tetek
Created August 2, 2016 13:56
Show Gist options
  • Select an option

  • Save tetek/e6a229b0461fc688f8e82f0e6377c564 to your computer and use it in GitHub Desktop.

Select an option

Save tetek/e6a229b0461fc688f8e82f0e6377c564 to your computer and use it in GitHub Desktop.
jspb.BinaryWriter.prototype.writeString=function(a,b){
if(null!=b){
this.rawWriteFieldHeader_(a,jspb.BinaryConstants.WireType.DELIMITED);
for(var c=[],d=0; d < b.length; d++) {
var e = b.codePointAt(d);
if (e < 128) {
c.push(e)
}
else if (e < 2048){
c.push(e>>6|192)
c.push(e&63|128)
}
else if (e < 65536) {
c.push(e>>12|224)
c.push(e>>6&63|128)
c.push(e&63|128)
}
else {
c.push(e>>18|240)
c.push((e>>12)&63|224)
c.push(e>>6&63|128)
c.push(e&63|128)
}
}
this.rawWriteUnsignedVarint32(c.length);this.appendArray_(c)
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment