#pragma once #include #include #include #include struct UConverter; namespace DB { class MySQLCharset final : boost::noncopyable { public: ~MySQLCharset(); String getCharsetFromId(UInt32 id); Int32 convertFromId(UInt32 id, String & to, const String & from); Int32 convert(const String & charset, String & to, const String & from); bool needConvert(UInt32 id); static bool needConvert(const String & charset); static bool isCharsetAvailable(const String & name); private: std::mutex mutex; std::unordered_map conv_cache; UConverter * getCachedConverter(const String & charset); static const std::unordered_map charsets; }; using MySQLCharsetPtr = std::shared_ptr; }