コード例 #1
0
 public static string ReadString(MemBlock b, int offset, out int bytelength)
 {
   int null_idx = b.IndexOf(0, offset);
   int raw_length = null_idx - offset;
   bytelength = raw_length + 1; //One for the null
   Encoding e;
   /*
    * Benchmarks of mono show this to be about twice as fast as just
    * using UTF8.  That really means UTF8 could be optimized in mono
    */
   if( b.IsAscii(offset, raw_length) ) {
     e = Encoding.ASCII;
   } else {
     e = Encoding.UTF8;
   }
   return b.GetString(e, offset, raw_length);
 }