On 12/03/2009 13:36, Mathias Bauer wrote:
Rainman Lee wrote:
Hi Andrew
I know that implicit conversions usually bring more side effects than
convenience. But it is not the reason that we should give all them up
I think ;)
There is no implicit conversion from std::string to const char*,
because if a string is destroyed, the pointer to its content will be
invalid.
No, there indeed is no implicit conversion primarily for the reason
mentioned by Andrew (at least the "inventor" of this class told me so
many years ago): developers should not inadvertedly pass non-ascii
character strings to a UniCode string ctor. Creating a UniCode string
from a character string always needs an accompanying string encoding as
parameter.
if the inventor of OUString was indeed so conscientious, then i really
have to wonder...
here's a little quiz (and don't ask me why i know this):
why does the following program (compiled without warning by sunCC and
gcc4.2) do what it does:
#include <rtl/ustring.hxx>
#include <stdio.h>
int main()
{
::rtl::OUString foo( ::rtl::OUString::createFromAscii("foo") );
::rtl::OUString bar(foo + sal_Unicode(1) + foo);
printf("result: %s\n",
::rtl::OUStringToOString(bar, RTL_TEXTENCODING_UTF8).getStr());
}
> ./unxsoli4.pro/bin/test
result: oofoo
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]