Logo Search packages:      
Sourcecode: libpodofo version File versions  Download package

void PoDoFo::PdfLocaleImbue ( std::ios_base &   )

Imbue the passed stream with a locale that will be safe to do I/O of the low level PDF format with.

PDF document structure I/O is done with the C++ standard library IOStreams code. By default, this will adapt to the current locale. That's not good at all when doing I/O of PDF data structures, which follow POSIX/english locale conventions irrespective of runtime locale. Make sure to to call this function on any stream you intend to use for PDF I/O. Avoid using this stream for anything that should be done in the regional locale.

This method may throw ePdfError_InvalidDeviceOperation if your STL does not support the locale string in PdfIOLocale .

If you fail to call this on a stream you use for PDF I/O you will encounter problems like German and other European users getting numbers in the format "10110,4" or even "10.110,4" instead of "10110.4" .

Definition at line 12 of file PdfLocale.cpp.

References ePdfError_InvalidDeviceOperation, PdfIOLocale, and PODOFO_RAISE_ERROR_INFO.

Referenced by PoDoFo::PdfColor::FromString(), PoDoFo::PdfField::Init(), PoDoFo::PdfFont::InitVars(), PoDoFo::PdfExtGState::PdfExtGState(), PoDoFo::PdfFont::PdfFont(), PoDoFo::PdfInputDevice::PdfInputDevice(), PoDoFo::PdfOutputDevice::PdfOutputDevice(), PoDoFo::PdfPainter::PdfPainter(), PoDoFo::PdfShadingPattern::PdfShadingPattern(), PoDoFo::PdfXObject::PdfXObject(), and PoDoFo::PdfVariant::Write().

    static const std::locale cachedLocale( PdfIOLocale );
    try {
      s.imbue( cachedLocale );
    } catch (const std::runtime_error & e) {
        std::ostringstream s;
        s << "Failed to set safe locale on stream being used for PDF I/O.";
        s << "Locale set was: \"" << PdfIOLocale << "\".";
        s << "Error reported by STL std::locale: \"" << e.what() << "\"";
        // The info string is copied by PdfError so we're ok to just:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index