lib/bson/bson.js
function() {
    // Get the start search index
    var i = index;
    // Locate the end of the c string
    while(buffer[i] !== 0x00 && i < buffer.length) { 
      i++ 
    }
    // If are at the end of the buffer there is a problem with the document
    if(i >= buffer.length) throw new Error("Bad BSON Document: illegal CString")
    // Grab utf8 encoded string
    var string = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('utf8', index, i) : convertUint8ArrayToUtf8String(buffer, index, i);
    // Update index position
    index = i + 1;
    // Return string
    return string;
  }
function() {
    // Get the start search index
    var i = index;
    // Locate the end of the c string
    while(buffer[i] !== 0x00 && i < buffer.length) { 
      i++ 
    }
    // If are at the end of the buffer there is a problem with the document
    if(i >= buffer.length) throw new Error("Bad BSON Document: illegal CString")
    // Grab utf8 encoded string
    var string = supportsBuffer && Buffer.isBuffer(buffer) ? buffer.toString('utf8', index, i) : convertUint8ArrayToUtf8String(buffer, index, i);
    // Update index position
    index = i + 1;
    // Return string
    return string;
  }
function ( ) { // Get the start search index var i = index ; // Locate the end of the c string while ( buffer [ i ] !== 0x00 && i < buffer . length ) { i ++ } // If are at the end of the buffer there is a problem with the document if ( i >= buffer . length ) throw new Error ( "Bad BSON Document: illegal CString" ) // Grab utf8 encoded string var string = supportsBuffer && Buffer . isBuffer ( buffer ) ? buffer . toString ( 'utf8' , index , i ) : convertUint8ArrayToUtf8String ( buffer , index , i ) ; // Update index position index = i + 1 ; // Return string return string ; }
Reads in a C style string
Reads in a C style string