¿Desea utilizarlo o, por alguna razón, insista en el código?
En mi sistema Debian, parece que el comando strings
puede hacerlo de la caja. Ver el exercept de la página de manual:
--encoding=encoding
Select the character encoding of the strings that are to be found. Possible values for encoding are: s = single-7-bit-byte characters (ASCII, ISO 8859,
etc., default), S = single-8-bit-byte characters, b = 16-bit bigendian, l = 16-bit littleendian, B = 32-bit bigendian, L = 32-bit littleendian. Useful
for finding wide character strings.
Editar: OK. No sé C# así que esto puede ser un poco peludo, pero básicamente, necesitas buscar secuencias de ceros alternados y caracteres ingleses.
byte b;
int i=0;
while(!endOfInput()) {
b=getNextByte();
LoopBegin:
if(!isEnglish(b)) {
if(i>0) // report successful match of length i
i=0;
continue;
}
if(endOfInput()) break;
if((b=getNextByte())!=0)
goto LoopBegin;
i++; // found another character
}
Esto debería funcionar para little-endian.
Para inglés solamente y UTF-8, las cadenas (1) ya deberían estar bien. – mouviciel
Si el idioma no importa, ¿por qué no comprueba el origen de la utilidad de cadenas en sí? –