Source/NFX.Erlang/Types/ErlBinary.cs
/// <summary>
/// Convert a byte buffer to printable binary representation (i.e. &lt;&lt;"abc...">>)
/// </summary>
Convert a byte buffer to printable binary representation
Convert a byte buffer to printable binary representation
public static string ToPrintableString(byte[] buf, int offset, int count, int maxLen = 0)
    {
      var printable = true;
      var n = maxLen == 0 ? offset + count : offset + Math.Min(count, maxLen);
      for (int i = offset; i < n; ++i)
      {
        var c = buf[i];
        if (c > 31 && c != 127 || c == 8 || c == 10 || c == 13)
          continue;
        printable = false;
        break;
      }
      return printable
           ? "<<\"{0}\">>".Args(buf.ToDumpString(DumpFormat.Printable, offset, count, maxLen: maxLen))
           : ToBinaryString(buf, offset, count, maxLen);
    }
public static string ToPrintableString ( byte [ ] buf , int offset , int count , int maxLen = 0 ) { var printable = true ; var n = maxLen == 0 ? offset + count : offset + Math . Min ( count , maxLen ) ; for ( int i = offset ; i < n ; ++ i ) { var c = buf [ i ] ; if ( c > 31 && c != 127 || c == 8 || c == 10 || c == 13 ) continue ; printable = false ; break ; } return printable ? " \" \" " . Args ( buf . ToDumpString ( DumpFormat . Printable , offset , count , maxLen : maxLen ) ) : ToBinaryString ( buf , offset , count , maxLen ) ; }
Convert a byte buffer to printable binary representation (i.e.
Convert a byte buffer to printable binary representation ( i . e .
buf
byte[]
offset
int
count
int
maxLen
int