Question about OUString::compareToAscii

Christophe JAILLET christophe.jaillet at wanadoo.fr
Fri Jul 13 14:37:55 PDT 2012


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 :))



More information about the LibreOffice mailing list