Allow specifying the replacement character in wxString::ToAscii()

Don't hardcode "_" as the replacement character but accept the one specified
by the user.

Closes https://github.com/wxWidgets/wxWidgets/pull/116
This commit is contained in:
Stefano D. Mtangoo
2016-01-02 17:32:22 +01:00
committed by Vadim Zeitlin
parent cfd4da8fdb
commit 28bc1bdac0
4 changed files with 13 additions and 8 deletions

View File

@@ -1205,7 +1205,7 @@ wxString wxString::FromAscii(char ascii)
return wxString(wxUniChar((wchar_t)c));
}
const wxScopedCharBuffer wxString::ToAscii() const
const wxScopedCharBuffer wxString::ToAscii(char replaceWith) const
{
// this will allocate enough space for the terminating NUL too
wxCharBuffer buffer(length());
@@ -1215,7 +1215,7 @@ const wxScopedCharBuffer wxString::ToAscii() const
{
wxUniChar c(*i);
// FIXME-UTF8: unify substituted char ('_') with wxUniChar ('?')
*dest++ = c.IsAscii() ? (char)c : '_';
*dest++ = c.IsAscii() ? (char)c : replaceWith;
// the output string can't have embedded NULs anyhow, so we can safely
// stop at first of them even if we do have any