Source/NFX.Erlang/ErlInputStream.cs
/// <summary>
/// Read Erlang string or list from the stream
/// </summary>
/// <returns></returns>
Read Erlang string or list from the stream
Read Erlang string or list from the stream
public ErlString ReadString()
      {
        var tag = readTag();
        string s;
        switch (tag)
        {
          case ErlExternalTag.String:
            var len   = Read2BE();
            s = m_Encoding.GetString(m_Buffer, m_Position, len);
            m_Position += len;
            break;
          case ErlExternalTag.Nil:
            s = string.Empty;
            break;
          case ErlExternalTag.List:
            var n = Read4BE();
            var b = new byte[n];
            for (int i = 0; i < n; i++)
              b[i] = Read1();
            readTag(ErlExternalTag.Nil);
            s = m_Encoding.GetString(b);
            break;
          default:
            throw new ErlException(StringConsts.ERL_INVALID_TERM_TYPE_ERROR,
                "string", tag.ToString());
        }
        return new ErlString(s);
      }
public ErlString ReadString ( ) { var tag = readTag ( ) ; string s ; switch ( tag ) { case ErlExternalTag . String : var len = Read2BE ( ) ; s = m_Encoding . GetString ( m_Buffer , m_Position , len ) ; m_Position += len ; break ; case ErlExternalTag . Nil : s = string . Empty ; break ; case ErlExternalTag . List : var n = Read4BE ( ) ; var b = new byte [ n ] ; for ( int i = 0 ; i < n ; i ++ ) b [ i ] = Read1 ( ) ; readTag ( ErlExternalTag . Nil ) ; s = m_Encoding . GetString ( b ) ; break ; default : throw new ErlException ( StringConsts . ERL_INVALID_TERM_TYPE_ERROR , " " , tag . ToString ( ) ) ; } return new ErlString ( s ) ; }
Read Erlang string or list from the stream
Read Erlang string or list from the stream
None