Vuoi semplicemente usarlo, o per qualche ragione insisti sul codice?
Sul mio sistema Debian, sembra che il comando strings
possa farlo immediatamente. Vedere l'exercept dalla manpage:
--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.
Modifica: OK. Non conosco C#, quindi potrebbe essere un po 'peloso, ma in pratica devi cercare sequenze di zeri alternati e caratteri inglesi.
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
}
Questo dovrebbe funzionare per little-endian.
Solo per l'inglese e UTF-8, le stringhe (1) dovrebbero già essere OK. – mouviciel
Se la lingua non è importante, allora perché non si controlla la fonte dell'utilità delle stringhe stessa? –