Skip to content

Instantly share code, notes, and snippets.

@donthorp
Created April 28, 2011 18:56
Show Gist options
  • Save donthorp/947031 to your computer and use it in GitHub Desktop.
Save donthorp/947031 to your computer and use it in GitHub Desktop.
Codec Numeric Examples
// Encode a 4 byte integer into position 10 using BIG_ENDIAN encoding
var buffer = Ti.createBuffer({ length: 100 });
Ti.Codec.encodeNumber({
source: 0x3456789a,
dest: buffer,
position: 10,
type: Ti.Codec.TYPE_INT,
byteOrder: Ti.Codec.BIG_ENDIAN
});
//Decode a 4 byte integer from position 10 using BIG_ENDIAN encoding
var value = Ti.Codec.decodeNumber({
source: buffer,
position: 10,
type: Ti.Codec.TYPE_INT,
byteOrder: Ti.Codec.BIG_ENDIAN
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment