i would rather make this something like sal unicode clastchar sal int npos atext getlength while  npos clastchar atext npos  x npos so we catch any number of trailing spaces and also do not attempt to access atext out of bounds 