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 _WIN32 00030 _snprintf(hex, 3, "%x", c); 00031 #else 00032 snprintf(hex, 3, "%x", c); 00033 #endif 00034 return hex; 00035 } 00036 00038 inline char hexToChar(const std::string& hex) 00039 { 00040 int c; 00041 if (sscanf(hex.c_str(), "%x", &c) == 1) { 00042 return (char) c; 00043 } else { 00044 return (char) 0; 00045 } 00046 } 00047 00048 const std::string hexEncodeWithPrefix(const std::string& prefix, 00049 const std::string& special, 00050 const std::string& message); 00051 00052 const std::string hexDecodeWithPrefix(const std::string& prefix, 00053 const std::string& message); 00054 00055 } } // namespace Atlas::Codecs 00056 00057 #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.