Atlas-C++
|
00001 // This file may be redistributed and modified under the terms of the 00002 // GNU Lesser General Public License (See COPYING for details). 00003 // Copyright (C) 2000 Stefanus Du Toit, Michael Day 00004 00005 // $Id$ 00006 00007 #ifndef ATLAS_CODECS_UTILITY_H 00008 #define ATLAS_CODECS_UTILITY_H 00009 00020 #include <cstdio> 00021 #include <string> 00022 00023 namespace Atlas { namespace Codecs { 00024 00026 inline const std::string charToHex(char c) 00027 { 00028 char hex[3]; 00029 #ifdef __MINGW32__ 00030 // Perhaps this should #ifdef _WIN32 instead? 00031 _snprintf(hex, 3, "%x", c); 00032 #else 00033 snprintf(hex, 3, "%x", c); 00034 #endif 00035 return hex; 00036 } 00037 00039 inline char hexToChar(const std::string& hex) 00040 { 00041 int c; 00042 if (sscanf(hex.c_str(), "%x", &c) == 1) { 00043 return (char) c; 00044 } else { 00045 return (char) 0; 00046 } 00047 } 00048 00049 const std::string hexEncodeWithPrefix(const std::string& prefix, 00050 const std::string& special, 00051 const std::string& message); 00052 00053 const std::string hexDecodeWithPrefix(const std::string& prefix, 00054 const std::string& message); 00055 00056 } } // namespace Atlas::Codecs 00057 00058 #endif // ATLAS_CODECS_UTILITY_H
Copyright 2000-2004 the respective authors.
This document can be licensed under the terms of the GNU Free Documentation License or the GNU General Public License and may be freely distributed under the terms given by one of these licenses.