Date: prev next · Thread: first prev next last
2017 Archives by date, by thread · List index


Hi,

On Sat, Dec 23, 2017 at 7:13 PM, Olivier Hallot
<olivier.hallot@libreoffice.org> wrote:
HI

Newbie seeking advice!

I am trying to implement Kendy's idea of a temp file with some HTML
inside, I seek a piece of code to open a temp file, write contents in
it, close it.

I started with
---------------
    OUString aExtension(".html");
    ::utl::TempFile aTempFile("newhelp", true, &aExtension, nullptr,
false );
    aTempFile.EnableKillingFile();
--------------

But then How do I write a simple OUString ("hello world") inside it?

continued from your example...

SvStream* pStream = aTempFile.GetStream(StreamMode::WRITE);
pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
pStream->WriteUnicodeOrByteText(OUString ("hello world"));
pStream->Close();
aTempFile.CloseStream();

As you can see this converts the OUString to UTF8 when you write it.
BTW. I didn't try to compile this, so it may be wrong :)

Thanks in advance.
Seasons Greetings!
Olivier

Best Regards,
Tomaž

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.