GetString() public method

public GetString ( System e ) : string
e System
return string
Exemplo n.º 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));
        }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
    virtual public void HandleData(MemBlock data, ISender return_path, object state)
    {
      Address addr = GetAddress(return_path);
      if(addr == null) {
        return;
      }
      _ondemand.Set(addr);

      try {
        _sub.Handle(data, return_path);
      } catch {
        string d_s = data.GetString(System.Text.Encoding.ASCII);
        ProtocolLog.WriteIf(ProtocolLog.Exceptions, String.Format(
              "Error handling packet from {0}, containing {1}",
              return_path, d_s));
      }
    }