> On Mon, 2011-09-26 at 09:43 +0200, Stephan Bergmann wrote: > > On 09/26/2011 01:30 AM, Neil Leathers wrote: > I was looking into the > > Easy Hacks: "Removal/Replacement of the String/UniString/ByteString > > with OUString/OString once and for all" and ran into needing to > > translate a SearchAndReplaceAscii. Before launching into this set I > > wanted to confirm that instead of moving the SearchAndReplace > > functions to OUString and OString they should be moved to > > OUStringBuffer and OStringBuffer? > > > > It would probably be better placed at OUString (where it returns a > > new OUString instance, leaving the original intact) than at > > OUStringBuffer (where it modifies this instance). > > See if comphelper::string::replace fits your needs, i.e. include > comphelper/string.hxx, it takes string to operate on, search string, > replace string and returns a new string. Where string is an OUString or > OString. > > comphelper/qa/string/test_string.cxx is the unit test for it, i.e. > TestString::testReplace if anyone wants to put any potential gotchas > through it.
This seems to work fine. I guess http://wiki.documentfoundation.org/Development/String_Classes should be updated? The table lists the following: xub_StrLen SearchAndReplace( sal_Unicode c, sal_Unicode cRep, xub_StrLen nIndex = 0 ); xub_StrLen SearchAndReplace( const UniString& rStr, const UniString& rRepStr, xub_StrLen nIndex = 0 ); xub_StrLen SearchAndReplace( const sal_Unicode* pCharStr, const UniString& rRepStr, xub_StrLen nIndex = 0 ); xub_StrLen SearchAndReplaceAscii( const sal_Char* pAsciiStr, const UniString& rRepStr, xub_StrLen nIndex = 0 ); void SearchAndReplaceAll( sal_Unicode c, sal_Unicode cRep ); void SearchAndReplaceAll( const UniString& rStr, const UniString& rRepStr ); void SearchAndReplaceAll( const sal_Unicode* pCharStr, const UniString& rRepStr ); void SearchAndReplaceAllAscii( const sal_Char* pAsciiStr, const UniString& rRepStr ); Neil Leathers _______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice