X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2Funicode.h;h=6e83180c10692edcbe03fcba4af10fb7a6d6c407;hb=c48091f33a773732fa6c789927e5833e44108d9d;hp=e3804350b314d367eaa0519a2309cddb6908726b;hpb=7c41973d518f733f32f38ba32f471abf11188f3c;p=lyx.git diff --git a/src/support/unicode.h b/src/support/unicode.h index e3804350b3..6e83180c10 100644 --- a/src/support/unicode.h +++ b/src/support/unicode.h @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Lars Gullik Bjønnes + * \author Lars Gullik Bjønnes * * Full author contact details are available in file CREDITS. * @@ -15,9 +15,7 @@ #include "support/strfwd.h" -#include - -#include +#include #include @@ -26,34 +24,31 @@ namespace lyx { class IconvProcessor { public: - IconvProcessor( - char const * tocode = "", - char const * fromcode = ""); + IconvProcessor(char const * tocode = "", char const * fromcode = ""); /// copy constructor needed because of pimpl_ IconvProcessor(IconvProcessor const &); /// assignment operator needed because of pimpl_ - IconvProcessor & operator=(IconvProcessor const &); - /// destructor (needs to be implemented in the .C file because the - /// boost::scoped_ptr destructor needs a fully defined type + void operator=(IconvProcessor const &); + /// destructor ~IconvProcessor(); /// convert any data from \c fromcode to \c tocode unicode format. /// \return the number of bytes of the converted output buffer. - int convert( - char const * in_buffer, - size_t in_size, - char * out_buffer, - size_t max_out_size); + int convert(char const * in_buffer, size_t in_size, + char * out_buffer, size_t max_out_size); + + /// source encoding + std::string from() const; + /// target encoding + std::string to() const; + private: /// open iconv. /// \return true if the processor is ready to use. bool init(); - - std::string tocode_; - std::string fromcode_; - - struct Private; - ::boost::scoped_ptr pimpl_; + /// hide internals + struct Impl; + Impl * pimpl_; }; // A single codepoint conversion for utf8_to_ucs4 does not make @@ -99,6 +94,8 @@ void ucs4_to_multibytes(char_type ucs4, std::vector & out, extern char const * ucs4_codeset; +/// How many bytes does one UCS4 code point use at most in encoding \p encoding? +int max_encoded_bytes(std::string const & encoding); } // namespace lyx