00001 #ifndef DVXML_ICONV_H 00002 #define DVXML_ICONV_H 00003 // $Id: dviconv.h,v 1.1 2003/05/24 12:28:42 dvermeir Exp $ 00004 00005 #include <string> 00006 #include <stdexcept> 00007 #include <dvutil/date.h> 00008 #include <xmlwrapp/xmlwrapp.h> 00009 00010 namespace Dv { 00011 namespace Xml { 00012 00013 /** Convert source C-string between character sets. 00014 * @param to_charset character set to convert to, e.g. "UTF8" 00015 * @param from_charset character set to convert from, e.g. "ISO-8859-1" 00016 * @param target string containing new version of source string. 00017 * @param source C-string 00018 * @exception std::runtime_error if anything goes wrong. 00019 * Use iconv --list to see all supported character sets. 00020 */ 00021 void iconv(const char* to_charset, const char* from_charset, 00022 std::string& target, const char* source) throw (std::runtime_error); 00023 00024 /** Convert source C-string between character sets. 00025 * @param to_charset character set to convert to, e.g. "UTF8" 00026 * @param from_charset character set to convert from, e.g. "ISO-8859-1" 00027 * @param target string containing new version of source string. 00028 * @param source C-string 00029 * @exception std::runtime_error if anything goes wrong. 00030 * Use iconv --list to see all supported character sets. 00031 */ 00032 void iconv(const char* to_charset, const char* from_charset, 00033 std::string& target, const std::string& source) throw (std::runtime_error); 00034 00035 /** Convert source C-string between character sets. 00036 * @param to_charset character set to convert to, e.g. "UTF8" 00037 * @param from_charset character set to convert from, e.g. "ISO-8859-1" 00038 * @param source C-string 00039 * @return string containing new version of source string (in target character set). 00040 * @exception std::runtime_error if anything goes wrong. 00041 * Use iconv --list to see all supported character sets. 00042 */ 00043 std::string iconv(const char* to_charset, const char* from_charset, 00044 const char* source) throw (std::runtime_error); 00045 00046 /** Convert source C-string between character sets. 00047 * @param to_charset character set to convert to, e.g. "UTF8" 00048 * @param from_charset character set to convert from, e.g. "ISO-8859-1" 00049 * @param source C-string 00050 * @return string containing new version of source string (in target character set). 00051 * @exception std::runtime_error if anything goes wrong. 00052 * Use iconv --list to see all supported character sets. 00053 */ 00054 std::string iconv(const char* to_charset, const char* from_charset, 00055 const std::string& source) throw (std::runtime_error); 00056 00057 /** Convert "ISO-8859-1" string to "UTF8" string. 00058 * @param source string (using "ISO-8859-1" character set). 00059 * @return string containing source string (in "UTF8" character set). 00060 * @exception std::runtime_error if anything goes wrong. 00061 * Use iconv --list to see all supported character sets. 00062 */ 00063 inline std::string iso2utf8(const std::string& source ) throw (std::runtime_error) { 00064 return iconv("UTF8", "ISO-8859-1", source); 00065 } 00066 00067 /** Convert "ISO-8859-1" C-string to "UTF8" string. 00068 * @param source string (using "ISO-8859-1" character set). 00069 * @return string containing source string (in "UTF8" character set). 00070 * @exception std::runtime_error if anything goes wrong. 00071 * Use iconv --list to see all supported character sets. 00072 */ 00073 inline std::string iso2utf8(const char* source ) throw (std::runtime_error) { 00074 return iconv("UTF8", "ISO-8859-1", source); 00075 } 00076 00077 00078 }} 00079 #endif 00080
dvxml-0.1.4 | [19 September, 2003] |