[dev] Re: OUString
Thank you for your reply. On Tue, Apr 26, 2011 at 1:16 PM, Mathias Bauer wrote: > On 26.04.2011 08:07, Rohit Kulkarni wrote: > >> How do I convert OUString to normal const char * in .cxx file. >> Because I am using ldap_open(const char*,int) function which has const >> char* as parameter. >> >> Regards, >> Rohit >> > > rtl::OUString objects contain UniCode strings. If you want to convert them > to a char* you need to provide an encoding that shall be used, e.g. > RTL_TEXTENCODING_UTF8. With this encoding you can do it this way: > > const char* p = rtl::OString( >myOUString.getStr(), myOUString.getLength(), >RTL_TEXTENCODING_UTF8 ).getStr(); > > Regards, > Mathias > > -- > Mathias Bauer (mba) - Project Lead OpenOffice.org Writer > OpenOffice.org Engineering at Oracle: http://blogs.sun.com/GullFOSS > Please don't reply to "nospamfor...@gmx.de". > I use it for the OOo lists and only rarely read other mails sent to it. > -- > - > To unsubscribe send email to dev-unsubscr...@openoffice.org > For additional commands send email to sy...@openoffice.org > with Subject: help > -- - To unsubscribe send email to dev-unsubscr...@openoffice.org For additional commands send email to sy...@openoffice.org with Subject: help
[dev] Re: OUString
On 26.04.2011 08:07, Rohit Kulkarni wrote: How do I convert OUString to normal const char * in .cxx file. Because I am using ldap_open(const char*,int) function which has const char* as parameter. On 2011/04/26 16:46, Mathias Bauer wrote: rtl::OUString objects contain UniCode strings. If you want to convert them to a char* you need to provide an encoding that shall be used, e.g. RTL_TEXTENCODING_UTF8. With this encoding you can do it this way: const char* p = rtl::OString( myOUString.getStr(), myOUString.getLength(), RTL_TEXTENCODING_UTF8 ).getStr(); And the same as what Mathias suggests: http://hg.services.openoffice.org/DEV300/file/tip/sal/rtl/source/debugprint.cxx http://hg.services.openoffice.org/DEV300/file/tip/sal/osl/all/utility.cxx http://hg.services.openoffice.org/DEV300/file/tip/sal/inc/sal/types.h Those functions and methods might also be useful when you want print the string in your debugger. To learn about OUString, look into sal/inc/rtl/ and sal/rtl/source/ Regards, Tora -- - To unsubscribe send email to dev-unsubscr...@openoffice.org For additional commands send email to sy...@openoffice.org with Subject: help
[dev] Re: OUString
On 26.04.2011 08:07, Rohit Kulkarni wrote: How do I convert OUString to normal const char * in .cxx file. Because I am using ldap_open(const char*,int) function which has const char* as parameter. Regards, Rohit rtl::OUString objects contain UniCode strings. If you want to convert them to a char* you need to provide an encoding that shall be used, e.g. RTL_TEXTENCODING_UTF8. With this encoding you can do it this way: const char* p = rtl::OString( myOUString.getStr(), myOUString.getLength(), RTL_TEXTENCODING_UTF8 ).getStr(); Regards, Mathias -- Mathias Bauer (mba) - Project Lead OpenOffice.org Writer OpenOffice.org Engineering at Oracle: http://blogs.sun.com/GullFOSS Please don't reply to "nospamfor...@gmx.de". I use it for the OOo lists and only rarely read other mails sent to it. -- - To unsubscribe send email to dev-unsubscr...@openoffice.org For additional commands send email to sy...@openoffice.org with Subject: help
[dev] Re: OUString
On 26/03/2011 06:49, Rohit Kulkarni wrote: > How can I see the value of an OUString variable in gdb? > > Regards, > Rohit you can add some functions to the gdb configuration that allow printing the various string types used in OOo: http://wiki.services.openoffice.org/wiki/Debugging -- "If rascals knew how much money could be made in being righteous, they would be righteous out of plain rascality!" -- Mark Twain -- - To unsubscribe send email to dev-unsubscr...@openoffice.org For additional commands send email to sy...@openoffice.org with Subject: help