char GetCharInChunk(object chunk, int index)
{
AssertChunkObject(chunk);
if (chunk.GetType() == typeof(string)) return ((string)chunk)[index];
if (chunk.GetType() == typeof(byte[])) return (char)((byte[])chunk)[index];
if (chunk.GetType() == typeof(PhpString)) return ((PhpString)chunk)[index];
if (chunk.GetType() == typeof(char[])) return ((char[])chunk)[index];
throw new ArgumentException(chunk.GetType().ToString());
}