Question about OUString::compareToAscii

Stephan Bergmann sbergman at
Mon Jul 16 01:39:59 PDT 2012

On 07/13/2012 11:37 PM, Christophe JAILLET wrote:
> Le 13/07/2012 23:17, Lubos Lunak a écrit :
>>> according to my understanding,
>>> OUString::compareToAscii(RTL_CONSTASCII_STRINGPARAM("A string")) gives
>>   compareAsciiL - the L means it gets the string length from the macro
> I was speaking about compareToAscii, without the L. compareAsciiL does
> not seem to exist anyway.
>       sal_Int32 compareToAscii( const sal_Char * asciiStr, sal_Int32
> maxLength ) const SAL_THROW(())
> OUString str_1("abc");
> str_1.compareToAscii("a")                             --> should give false
> str_1.compareToAscii(RTL_CONSTASCII_STRINGPARAM("a")) --> should give
> true because only the first char of the 2 strings will be compared
> In fact I made the same mistake as you. RTL_CONSTASCII_STRINGPARAM made
> me think about the length of the literal but in this case, it also has a
> real effect on the result (unless I'm wrong :))

Indeed, see 
"Confusing behavior of cmopareToAscii overloads."  That's probably the 
reason why Lubos left compareToAscii alone when adding the string 
literal overloads.


More information about the LibreOffice mailing list