ascii_chk.c 925 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*!
  2. * \file lib/gis/ascii_chk.c
  3. *
  4. * \brief GIS Library - Remove non-ascii characters
  5. *
  6. * (C) 2001-2014 by the GRASS Development Team
  7. *
  8. * This program is free software under the GNU General Public License
  9. * (>=v2). Read the file COPYING that comes with GRASS for details.
  10. *
  11. * \author GRASS GIS Development Team
  12. *
  13. * \date 1999-2014
  14. */
  15. #include <grass/gis.h>
  16. #define TAB 011
  17. #define SPACE 040
  18. /**
  19. * \brief Removes non-ascii characters from buffer.
  20. *
  21. * Updates <b>string</b> with non_ascii characters removed, except for
  22. * tabs, which are turned into spaces.
  23. *
  24. * \param[in,out] string buffer to have non-ascii characters removed
  25. * \return
  26. */
  27. void G_ascii_check(char *string)
  28. {
  29. char *ptr1, *ptr2;
  30. ptr1 = string;
  31. ptr2 = string;
  32. while (*ptr1) {
  33. if ((*ptr1 >= 040) && (*ptr1 <= 0176))
  34. *ptr2++ = *ptr1;
  35. else if (*ptr1 == TAB)
  36. *ptr2++ = SPACE;
  37. ptr1++;
  38. }
  39. *ptr2 = 0;
  40. }