public static void StripSpaces( char[] value, int index, ref int len ) {
if ( len <= 0 ) {
return;
}
int startPos = index;
int endPos = index + len;
while ( value[startPos] == 0x20 ) {
startPos++;
if ( startPos == endPos ) {
len = 1;
return;
}
}
int offset = startPos - index;
int i;
for ( i = startPos; i < endPos; i++ ) {
char ch;
if ( ( ch = value[i] ) == 0x20 ) {
int j = i + 1;
while ( j < endPos && value[j] == 0x20 ) {
j++;
}
if ( j == endPos ) {
offset += ( j - i );
break;
}
if ( j > i+1 ) {
offset += ( j - i - 1 );
i = j - 1;
}
}
value[i-offset] = ch;
}
len -= offset;
}