15 #ifndef INCG_IRIS_IUTEST_CHARCODE_HPP_D444FB3E_3AFA_46D0_AD69_33FAAF5615E3_
16 #define INCG_IRIS_IUTEST_CHARCODE_HPP_D444FB3E_3AFA_46D0_AD69_33FAAF5615E3_
25 #if IUTEST_HAS_CXX_HDR_CODECVT
30 IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN()
45 inline ::std::string AnyStringToMultiByteString(
const char* str,
int num = -1)
47 return num < 0 ? str : ::std::string(str, static_cast<size_t>(num));
56 inline ::std::string AnyStringToMultiByteString(
const signed char* str,
int num = -1)
58 return AnyStringToMultiByteString(
reinterpret_cast<const char*
>(str), num);
67 ::std::string AnyStringToUTF8(
const wchar_t* str,
int num=-1);
75 ::std::string AnyStringToMultiByteString(
const wchar_t* str,
int num=-1);
77 #if IUTEST_HAS_CHAR16_T
85 ::std::string AnyStringToUTF8(
const char16_t* str,
int num=-1);
93 ::std::string AnyStringToMultiByteString(
const char16_t* str,
int num=-1);
97 #if IUTEST_HAS_CHAR32_T
105 ::std::string AnyStringToUTF8(
const char32_t* str,
int num = -1);
113 ::std::string AnyStringToMultiByteString(
const char32_t* str,
int num = -1);
122 ::std::wstring MultiByteStringToWideString(
const char* str);
130 ::std::string MultiByteStringToUTF8(
const char* str,
int num=-1);
137 template<
typename CharType>
138 ::std::string ShowAnyCString(
const CharType* any_c_str)
140 if( any_c_str == NULL )
142 return kStrings::Null;
144 return AnyStringToMultiByteString(any_c_str);
147 #if IUTEST_HAS_CXX_HDR_CODECVT
149 template<
typename In,
typename Out,
typename State>
150 struct codecvt :
public ::std::codecvt<In, Out, State> { ~codecvt() {} };
157 #if defined(_MSC_VER)
158 template<
typename In,
typename Out,
typename State>
159 ::std::basic_string<Out> CodeConvert(
const In* str, ::std::locale loc = ::std::locale(
""))
161 ::std::wstring_convert< codecvt<In, Out, State>, In> conv(&::std::use_facet< codecvt<In, Out, State> >(loc));
162 return conv.to_bytes(str);
165 template<
typename In,
typename Out,
typename State>
166 ::std::basic_string<Out> CodeConvert(
const In* str)
168 ::std::wstring_convert< codecvt<In, Out, State>, In> conv;
170 return conv.to_bytes(str);
178 namespace mbs_ptr_impl
184 const char* ptr(
const char* arg) {
return arg; }
186 struct wcs_to_mbs_ptr
189 const char* ptr(
const wchar_t* arg)
191 m_arg = ShowAnyCString(arg);
192 return m_arg.c_str();
196 struct to_mbs_ptr<wchar_t> :
public wcs_to_mbs_ptr {};
198 struct to_mbs_ptr<const wchar_t> :
public wcs_to_mbs_ptr {};
205 template<
typename CharType>
206 struct mbs_ptr :
public mbs_ptr_impl::to_mbs_ptr<CharType>
212 #if IUTEST_HAS_EXTERN_TEMPLATE
214 IUTEST_PRAGMA_EXTERN_TEMPLATE_WARN_DISABLE_BEGIN()
216 extern template struct mbs_ptr<char>;
217 extern template struct mbs_ptr<wchar_t>;
219 IUTEST_PRAGMA_EXTERN_TEMPLATE_WARN_DISABLE_END()
223 template struct mbs_ptr<char>;
224 template struct mbs_ptr<wchar_t>;
229 IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END()
235 # include "../impl/iutest_charcode.ipp"
iris unit test 定数 定義 ファイル
iutest root namespace
Definition: iutest_charcode.hpp:33