Skip to content

Instantly share code, notes, and snippets.

@tetek
Created August 2, 2016 11:23
Show Gist options
  • Select an option

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

Select an option

Save tetek/11fe15935d5269bf72103c5a85f4f2d9 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.charCodeAt(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