On 08/15/08 11:03, Vern Sun wrote:
Hi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
Reference< XTextDocument > xTextDoc ( xComponent, UNO_QUERY );
Reference< XSearchable > xSearchable ( xTextDoc, UNO_QUERY );
Reference< XSearchDescriptor > xSearchDesc =
xSearchable->createSearchDescriptor();
// xSearchDesc->setSearchString( OUString::createFromAscii( "swhss" ) );
// OUString sWrongString = OUSTring::createFromAscii("分区");
OUString sGoodString = OUString("分区", 4, RTL_TEXTENCODING_ISO_8859_15);
OString key = OUStringToOString(sGoodString, RTL_TEXTENCODING_UTF8);
???
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
How can I convert the key from OString format to the OUString format so that I
can search it?
How is your C++ compiler treating non-ASCII characters in string
literals (and what is the encoding of your C++ source file)?
If your C++ source file is UTF-8 encoded, and your C++ compiler does not
spoil this, it *might* work to do
OUString("分区", 6, RTL_TEXTENCODING_UTF8);
or equivalent
OUString(RTL_CONSTASCII_STRINGPARAM("分区"), RTL_TEXTENCODING_UTF8);
However, in any event, it is better to avoid non-ASCII characters in
your C++ source file (and if your file were part of the OOo code base,
it would be illegal if it contained non-ASCII characters). Use
something like
OUString("\xE5\x88\x86\xE5\x8C\xBA", 6, RTL_TEXTENCODING_UTF8);
// U+5206, U+533A
or
sal_Unicode const b[] = { 0x5206, 0x533A };
OUString(b, 2);
instead.
-Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]