Locale-savvy isspace

From Adobe Open Source Wiki
Revision as of 18:24, 24 July 2006 by FosterBrereton (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

isspace() relies on the locale() - we currently document the CEL parser as assuming the "C" locale - we should note the same requirement in the XML parser. Later it would be good to have a library providing this functionality which is wired to utf encoding - most likely this would be along the lines of the current parser syntax - something like the following:

namespace implementation {

template<std::size_t S>
struct is_space;

struct is_space<1>
	template<typename I>
	bool operator()(I& x) const
		if (space_table[*x]) { ++x; return true; }
		return false;

struct is_space<2>

} // namespace implementation

template<typename I> // I models InputIterator where value_type(I) == UTF encoded character
bool adobe::is_space(I& x)
	return adobe::implementation::is_space<sizeof(std::iterator_traits<I>::value_type)>()(x)