encoding.h
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOSTER_LOCALE_ENCODING_H_INCLUDED
#define BOOSTER_LOCALE_ENCODING_H_INCLUDED
#include <booster/config.h>
#ifdef BOOSTER_MSVC
# pragma warning(push)
# pragma warning(disable : 4275 4251 4231 4660)
#endif
#include <booster/locale/info.h>
#include <booster/locale/encoding_errors.h>
#include <booster/locale/encoding_utf.h>
namespace booster {
namespace locale {
namespace conv {
template<typename CharType>
std::basic_string<CharType> to_utf(char const *begin,char const *end,std::string const &charset,method_type how=default_method);
template<typename CharType>
std::string from_utf(CharType const *begin,CharType const *end,std::string const &charset,method_type how=default_method);
template<typename CharType>
std::basic_string<CharType> to_utf(char const *begin,char const *end,std::locale const &loc,method_type how=default_method)
{
return to_utf<CharType>(begin,end,std::use_facet<info>(loc).encoding(),how);
}
template<typename CharType>
std::string from_utf(CharType const *begin,CharType const *end,std::locale const &loc,method_type how=default_method)
{
return from_utf(begin,end,std::use_facet<info>(loc).encoding(),how);
}
template<typename CharType>
std::basic_string<CharType> to_utf(std::string const &text,std::string const &charset,method_type how=default_method)
{
return to_utf<CharType>(text.c_str(),text.c_str()+text.size(),charset,how);
}
template<typename CharType>
std::string from_utf(std::basic_string<CharType> const &text,std::string const &charset,method_type how=default_method)
{
return from_utf(text.c_str(),text.c_str()+text.size(),charset,how);
}
template<typename CharType>
std::basic_string<CharType> to_utf(char const *text,std::string const &charset,method_type how=default_method)
{
char const *text_end = text;
while(*text_end)
text_end++;
return to_utf<CharType>(text,text_end,charset,how);
}
template<typename CharType>
std::string from_utf(CharType const *text,std::string const &charset,method_type how=default_method)
{
CharType const *text_end = text;
while(*text_end)
text_end++;
return from_utf(text,text_end,charset,how);
}
template<typename CharType>
std::basic_string<CharType> to_utf(std::string const &text,std::locale const &loc,method_type how=default_method)
{
return to_utf<CharType>(text.c_str(),text.c_str()+text.size(),loc,how);
}
template<typename CharType>
std::string from_utf(std::basic_string<CharType> const &text,std::locale const &loc,method_type how=default_method)
{
return from_utf(text.c_str(),text.c_str()+text.size(),loc,how);
}
template<typename CharType>
std::basic_string<CharType> to_utf(char const *text,std::locale const &loc,method_type how=default_method)
{
char const *text_end = text;
while(*text_end)
text_end++;
return to_utf<CharType>(text,text_end,loc,how);
}
template<typename CharType>
std::string from_utf(CharType const *text,std::locale const &loc,method_type how=default_method)
{
CharType const *text_end = text;
while(*text_end)
text_end++;
return from_utf(text,text_end,loc,how);
}
BOOSTER_API
std::string between(char const *begin,
char const *end,
std::string const &to_encoding,
std::string const &from_encoding,
method_type how=default_method);
inline
std::string between(char const *text,
std::string const &to_encoding,
std::string const &from_encoding,
method_type how=default_method)
{
char const *end=text;
while(*end)
end++;
return booster::locale::conv::between(text,end,to_encoding,from_encoding,how);
}
inline
std::string between(std::string const &text,
std::string const &to_encoding,
std::string const &from_encoding,
method_type how=default_method)
{
return booster::locale::conv::between(text.c_str(),text.c_str()+text.size(),to_encoding,from_encoding,how);
}
template<>
BOOSTER_API std::basic_string<char> to_utf(char const *begin,char const *end,std::string const &charset,method_type how);
template<>
BOOSTER_API std::string from_utf(char const *begin,char const *end,std::string const &charset,method_type how);
template<>
BOOSTER_API std::basic_string<wchar_t> to_utf(char const *begin,char const *end,std::string const &charset,method_type how);
template<>
BOOSTER_API std::string from_utf(wchar_t const *begin,wchar_t const *end,std::string const &charset,method_type how);
#ifdef BOOSTER_HAS_CHAR16_T
template<>
BOOSTER_API std::basic_string<char16_t> to_utf(char const *begin,char const *end,std::string const &charset,method_type how);
template<>
BOOSTER_API std::string from_utf(char16_t const *begin,char16_t const *end,std::string const &charset,method_type how);
#endif
#ifdef BOOSTER_HAS_CHAR32_T
template<>
BOOSTER_API std::basic_string<char32_t> to_utf(char const *begin,char const *end,std::string const &charset,method_type how);
template<>
BOOSTER_API std::string from_utf(char32_t const *begin,char32_t const *end,std::string const &charset,method_type how);
#endif
} // conv
} // locale
} // boost
#ifdef BOOSTER_MSVC
#pragma warning(pop)
#endif
#endif
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
booster::locale::conv::default_method
Default method - skip.
Definition: encoding_errors.h:57
booster::locale::conv::method_type
method_type
Definition: encoding_errors.h:54