Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


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

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.