typename ucs4_convert_impl::enableif<TD, typename TS::value_type>::type unicode_cast(const TS& source) //TD unicode_cast(const TS& source) { using namespace ucs4_convert_impl; typedef typename convert_impl<typename TD::value_type>::type t_impl_writer; typedef typename convert_impl<typename TS::value_type>::type t_impl_reader; typedef typename std::back_insert_iterator<TD> t_outputitor; typedef typename TS::const_iterator t_inputitor; TD res; try { t_outputitor inserter(res); iteratorwriter<t_outputitor> dst(inserter); t_inputitor i1 = source.begin(); t_inputitor i2 = source.end(); while(i1 != i2) { t_impl_writer::write (dst, t_impl_reader::read(i1, i2)); } } catch(utf8::invalid_utf8_exception&) { // TODO: use a ERR_.. stream but i dont know whether i can so to in header easily. std::cerr << "Failed to convert a string from " << t_impl_reader::get_name() << " to " << t_impl_writer::get_name() << "\n"; return res; } return res; }
void debug_ts() { for(TS::iterator iter = ts.begin(); iter != ts.end(); ++iter) { debug_->debug("(%s %s %s)", (char*)iter->get(0), (char*)iter->get(1), (char*)iter->get(2)); for(int i = 0; i < 1000; i++) ; } }