mirror of
https://github.com/jezhiggins/arabica
synced 2025-01-15 15:40:56 +01:00
Fixed normalize-space function for arbitrary string types. Convert the string to UTF8, normalise, convert back to whatever. Not the world's most efficent, I guess, but I can't think of a better alternative right now.
This commit is contained in:
parent
167f36ec74
commit
e894e03c89
1 changed files with 5 additions and 4 deletions
|
@ -395,9 +395,10 @@ public:
|
|||
virtual XPathValue<string_type>* evaluate(const DOM::Node<string_type>& context,
|
||||
const ExecutionContext<string_type, string_adaptor>& executionContext) const
|
||||
{
|
||||
string_type value = ((baseT::argCount() > 0) ? baseT::argAsString(0, context, executionContext) : nodeStringValue<string_type, string_adaptor>(context));
|
||||
typename string_adaptor::const_iterator i = string_adaptor::begin(value), ie = string_adaptor::end(value);
|
||||
typename string_adaptor::mutable_iterator p = string_adaptor::begin(value), pe = string_adaptor::end(value);
|
||||
string_type initial = ((baseT::argCount() > 0) ? baseT::argAsString(0, context, executionContext) : nodeStringValue<string_type, string_adaptor>(context));
|
||||
std::string value = string_adaptor::asStdString(initial);
|
||||
std::string::const_iterator i = value.begin(), ie = value.end();
|
||||
std::string::iterator p = value.begin(), pe = value.end();
|
||||
|
||||
// string leading space
|
||||
while((i != ie) && (XML::is_space(static_cast<wchar_t>(*i))))
|
||||
|
@ -415,7 +416,7 @@ public:
|
|||
if(p != ie)
|
||||
*p++ = 0;
|
||||
|
||||
return new StringValue<string_type, string_adaptor>(value);
|
||||
return new StringValue<string_type, string_adaptor>(string_adaptor::construct_from_utf8(value.c_str()));
|
||||
} // evaluate
|
||||
}; // class NormalizeSpaceFn
|
||||
|
||||
|
|
Loading…
Reference in a new issue