Here's some C(++) that I use to strip formatting codes in Phoenix (for toats); maybe you can base your code on it.
code:
void stripFormat(WCHAR *from, WCHAR *result) {
wcscpy(result, L"\0");
while (*from != L'\0') {
if (*from == L'·') {
from++;
if (*from == L'$') {
from++;
if (*from <= L'9' && *from >= L'0') from++;
if (*from <= L'9' && *from >= L'0') from++;
if (*from == L'#') from+=7;
}
else if (*from == L'0' ||
*from == L'\'' ||
*from == L'@' ||
*from == L'#' ||
*from == L'&')
from++;
continue;
}
wcsncat(result, from, 1);
from++;
}
}
Edit: Please, please, please! Make code preserve tabs!