Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaceInPlace std::wstring #4713

Open
micheleselea opened this issue Sep 27, 2024 · 1 comment
Open

replaceInPlace std::wstring #4713

micheleselea opened this issue Sep 27, 2024 · 1 comment
Assignees

Comments

@micheleselea
Copy link
Contributor

micheleselea commented Sep 27, 2024

It's not possible to use this

std::wstring wstr;
Poco::replaceInPlace(wstr, L"STRINGB", L"STRINGA");

due to a compile error in this line typename S::size_type fromLen = std::strlen(from); of String.h

template <class S>
S& replaceInPlace(S& str, const typename S::value_type* from, const typename S::value_type* to, typename S::size_type start = 0)
{
	poco_assert (*from);

	S result;
	typename S::size_type pos = 0;
	typename S::size_type fromLen = std::strlen(from); //**HERE**
	result.append(str, 0, start);
	do
	{
		pos = str.find(from, start);
		if (pos != S::npos)
		{
			result.append(str, start, pos - start);
			result.append(to);
			start = pos + fromLen;
		}
		else result.append(str, start, str.size() - start);
	}
	while (pos != S::npos);
	str.swap(result);
	return str;
}
@micheleselea
Copy link
Contributor Author

probably we can change the line in something like
typename S::size_type fromLen = S(from).length();

@obiltschnig obiltschnig self-assigned this Sep 28, 2024
@obiltschnig obiltschnig added this to 1.14 Sep 28, 2024
@obiltschnig obiltschnig added this to the Release 1.14.0 milestone Sep 28, 2024
@obiltschnig obiltschnig moved this to Done in 1.14 Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants