原文链接:http://www.boost.org/doc/libs/1_60_0/libs/algorithm/doc/html/the_boost_algorithm_library/Misc/hex.html
hex
头文件“boost/algorithm/hex.hpp” 包含了两个算法:hex、unhex以及他们各自的三个版本的变体。hex将一个序列元素转换为十六进制数,unhex功能正好相反。template <typename InputIterator, typename OutputIterator> OutputIterator hex ( InputIterator first, InputIterator last, OutputIterator out ); template <typename T, typename OutputIterator> OutputIterator hex ( const T *ptr, OutputIterator out ); template <typename Range, typename OutputIterator> OutputIterator hex ( const Range &r, OutputIterator out );
template <typename InputIterator, typename OutputIterator> OutputIterator unhex ( InputIterator first, InputIterator last, OutputIterator out ); template <typename T, typename OutputIterator> OutputIterator unhex ( const T *ptr, OutputIterator out ); template <typename Range, typename OutputIterator> OutputIterator unhex ( const Range &r, OutputIterator out );
hex ( "abcdef", out ) --> "616263646566" hex ( "32", out ) --> "3332" hex ( "abcdef", wout ) --> "006100620063006400650066" hex ( "32", wout ) --> "00330032" unhex ( "616263646566", out ) --> "abcdef" unhex ( "3332", out ) --> "32" unhex ( "616263646566", wout ) --> "\6162\6364\6566" ( i.e, a 3 character string ) unhex ( "3332", wout ) --> "\3233" ( U+3332, SQUARE HUARADDO ) unhex ( "3", out ) --> Error - not enough input unhex ( "32", wout ) --> Error - not enough input unhex ( "ACEG", out ) --> Error - non-hex input