]> git.lyx.org Git - lyx.git/blobdiff - src/support/unicode.cpp
Format and reversion code for new counter inset.
[lyx.git] / src / support / unicode.cpp
index 187d018f2bc03da066e011483d6c3b0e21cff8cf..5ea21aad0520cf231abf81c9b7eeb64e26f8e192 100644 (file)
@@ -19,9 +19,8 @@
 
 #include <iconv.h>
 
-#include <boost/cstdint.hpp>
-
 #include <cerrno>
+#include <cstdint>
 #include <map>
 #include <ostream>
 //Needed in MSVC
@@ -52,7 +51,7 @@ namespace lyx {
 
 struct IconvProcessor::Handler {
        // assumes cd is valid
-       Handler(iconv_t const cd) : cd(cd) {}
+       explicit Handler(iconv_t const cd) : cd(cd) {}
        ~Handler() {
                if (iconv_close(cd) == -1)
                        LYXERR0("Error returned from iconv_close(" << errno << ')');
@@ -62,7 +61,7 @@ struct IconvProcessor::Handler {
 
 
 IconvProcessor::IconvProcessor(string tocode, string fromcode)
-       : tocode_(tocode), fromcode_(fromcode)
+       : tocode_(move(tocode)), fromcode_(move(fromcode))
 {}
 
 
@@ -108,7 +107,7 @@ int IconvProcessor::convert(char const * buf, size_t buflen,
        // flush out remaining data. This is needed because iconv sometimes
        // holds back chars in the stream, waiting for a combination character
        // (see e.g. http://sources.redhat.com/bugzilla/show_bug.cgi?id=1124)
-       iconv(h_->cd, NULL, NULL, &outbuf, &outbytesleft);
+       iconv(h_->cd, nullptr, nullptr, &outbuf, &outbytesleft);
 
        //lyxerr << dec;
        //lyxerr << "Inbytesleft: " << inbytesleft << endl;
@@ -125,30 +124,18 @@ int IconvProcessor::convert(char const * buf, size_t buflen,
                        lyxerr << "E2BIG  There is not sufficient room at *outbuf." << endl;
                        break;
                case EILSEQ:
-                       lyxerr << "EILSEQ An invalid multibyte sequence"
-                               << " has been encountered in the input.\n"
-                               << "When converting from " << fromcode_
-                               << " to " << tocode_ << ".\n";
-                       lyxerr << "Input:" << hex;
-                       for (size_t i = 0; i < buflen; ++i) {
-                               // char may be signed, avoid output of
-                               // something like 0xffffffc2
-                               boost::uint32_t const b =
-                                       *reinterpret_cast<unsigned char const *>(buf + i);
-                               lyxerr << " 0x" << (unsigned int)b;
-                       }
-                       lyxerr << dec << endl;
-                       break;
                case EINVAL:
-                       lyxerr << "EINVAL An incomplete multibyte sequence"
-                               << " has been encountered in the input.\n"
+                       lyxerr << (errno == EINVAL
+                                  ? "EINVAL An incomplete "
+                                  : "EILSEQ An invalid ")
+                               << "multibyte sequence has been encountered in the input.\n"
                                << "When converting from " << fromcode_
                                << " to " << tocode_ << ".\n";
                        lyxerr << "Input:" << hex;
                        for (size_t i = 0; i < buflen; ++i) {
                                // char may be signed, avoid output of
                                // something like 0xffffffc2
-                               boost::uint32_t const b =
+                               uint32_t const b =
                                        *reinterpret_cast<unsigned char const *>(buf + i);
                                lyxerr << " 0x" << (unsigned int)b;
                        }
@@ -198,7 +185,7 @@ iconv_convert(IconvProcessor & processor, InType const * buf, size_t buflen)
        return vector<RetType>(tmp, tmp + bytes / sizeof(RetType));
 }
 
-} // anon namespace
+} // namespace
 
 
 IconvProcessor & utf8ToUcs4()
@@ -269,7 +256,7 @@ IconvProcessor & getProc(map<string, IconvProcessor> & processors,
                return it->second;
 }
 
-} //anon namespace
+} // namespace
 
 
 vector<char>
@@ -318,7 +305,7 @@ map<string, IconvProcessor> & ucs4To8bitProcessors()
        return *processors.localData();
 }
 
-}
+} // namespace
 
 vector<char>
 ucs4_to_eightbit(char_type const * ucs4str, size_t ls, string const & encoding)