Skip to content

Instantly share code, notes, and snippets.

@javisantana
Created February 21, 2010 18:28
Show Gist options
  • Save javisantana/310451 to your computer and use it in GitHub Desktop.
Save javisantana/310451 to your computer and use it in GitHub Desktop.
public void writeString(BinaryWriter w, string s)
{
byte[] utf8Bytes = System.Text.Encoding.UTF8.GetBytes(s);
w.Write((UInt32) utf8Bytes.Length);
if(utf8Bytes.Length > 0)
w.Write(utf8Bytes);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment