static byte[] ReadString(IBerInput input, ref int length)
{
var bytes = new byte[length];
if(length > 0)
{
for(int nIndex = 0; nIndex < length; nIndex++)
bytes[nIndex] = input.ReadByte();
// strip trailing zeroes
while(length > 0 && bytes[length - 1] == 0)
length--;
}
return bytes;
}