/// <summary> /// Feeds the bytes into the StringGather. /// </summary> private void FeedGath(StringGather gath, byte[] data, int offset, int length, int leadingBytes, bool showLeading, int trailingBytes, bool showTrailing) { int startOffset = offset; int strEndOffset = offset + length - trailingBytes; if (showLeading) { while (leadingBytes-- > 0) { gath.WriteByte(data[offset++]); } } else { offset += leadingBytes; } for (; offset < strEndOffset; offset++) { gath.WriteChar((char)(data[offset] & 0x7f)); } while (showTrailing && trailingBytes-- > 0) { gath.WriteByte(data[offset++]); } gath.Finish(); }
/// <summary> /// Feeds the bytes into the StringGather. /// </summary> private void FeedGath(StringGather gath, byte[] data, int offset, int length, RevMode revMode, int leadingBytes, bool showLeading, int trailingBytes, bool showTrailing) { int startOffset = offset; int strEndOffset = offset + length - trailingBytes; if (showLeading) { while (leadingBytes-- > 0) { gath.WriteByte(data[offset++]); } } else { offset += leadingBytes; } if (revMode == RevMode.BlockReverse) { const int maxPerLine = MAX_OPERAND_LEN - 2; int numBlockLines = (length + maxPerLine - 1) / maxPerLine; for (int chunk = 0; chunk < numBlockLines; chunk++) { int chunkOffset = startOffset + chunk * maxPerLine; int endOffset = chunkOffset + maxPerLine; if (endOffset > strEndOffset) { endOffset = strEndOffset; } for (int off = endOffset - 1; off >= chunkOffset; off--) { gath.WriteChar((char)(data[off] & 0x7f)); } } } else { for (; offset < strEndOffset; offset++) { if (revMode == RevMode.Forward) { gath.WriteChar((char)(data[offset] & 0x7f)); } else if (revMode == RevMode.Reverse) { int posn = startOffset + (strEndOffset - offset) - 1; gath.WriteChar((char)(data[posn] & 0x7f)); } else { Debug.Assert(false); } } } while (showTrailing && trailingBytes-- > 0) { gath.WriteByte(data[offset++]); } gath.Finish(); }