Botan::Charset Namespace Reference


Functions

bool caseless_cmp (char a, char b)
byte char2digit (char c)
char digit2char (byte b)
bool is_digit (char c)
bool is_space (char c)
std::string transcode (const std::string &str, Character_Set to, Character_Set from)

Function Documentation

bool BOTAN_DLL Botan::Charset::caseless_cmp ( char  a,
char  b 
)

Definition at line 193 of file charset.cpp.

Referenced by Botan::x500_name_cmp().

00194    {
00195    return (std::tolower(static_cast<unsigned char>(a)) ==
00196            std::tolower(static_cast<unsigned char>(b)));
00197    }

byte BOTAN_DLL Botan::Charset::char2digit ( char  c  ) 

Definition at line 149 of file charset.cpp.

Referenced by Botan::BigInt::decode(), and Botan::to_u32bit().

00150    {
00151    switch(c)
00152       {
00153       case '0': return 0;
00154       case '1': return 1;
00155       case '2': return 2;
00156       case '3': return 3;
00157       case '4': return 4;
00158       case '5': return 5;
00159       case '6': return 6;
00160       case '7': return 7;
00161       case '8': return 8;
00162       case '9': return 9;
00163       }
00164 
00165    throw Invalid_Argument("char2digit: Input is not a digit character");
00166    }

char BOTAN_DLL Botan::Charset::digit2char ( byte  b  ) 

Definition at line 171 of file charset.cpp.

Referenced by Botan::BigInt::encode(), and Botan::to_string().

00172    {
00173    switch(b)
00174       {
00175       case 0: return '0';
00176       case 1: return '1';
00177       case 2: return '2';
00178       case 3: return '3';
00179       case 4: return '4';
00180       case 5: return '5';
00181       case 6: return '6';
00182       case 7: return '7';
00183       case 8: return '8';
00184       case 9: return '9';
00185       }
00186 
00187    throw Invalid_Argument("digit2char: Input is not a digit");
00188    }

bool BOTAN_DLL Botan::Charset::is_digit ( char  c  ) 

Definition at line 128 of file charset.cpp.

Referenced by Botan::BigInt::decode(), Botan::EAC_Time::set_to(), Botan::X509_Time::set_to(), and Botan::timespec_to_u32bit().

00129    {
00130    if(c == '0' || c == '1' || c == '2' || c == '3' || c == '4' ||
00131       c == '5' || c == '6' || c == '7' || c == '8' || c == '9')
00132       return true;
00133    return false;
00134    }

bool BOTAN_DLL Botan::Charset::is_space ( char  c  ) 

Definition at line 139 of file charset.cpp.

Referenced by Botan::BigInt::decode(), Botan::PGP_decode(), and Botan::x500_name_cmp().

00140    {
00141    if(c == ' ' || c == '\t' || c == '\n' || c == '\r')
00142       return true;
00143    return false;
00144    }

std::string BOTAN_DLL Botan::Charset::transcode ( const std::string &  str,
Character_Set  to,
Character_Set  from 
)

Definition at line 103 of file charset.cpp.

References Botan::LATIN1_CHARSET, Botan::LOCAL_CHARSET, Botan::to_string(), Botan::UCS2_CHARSET, and Botan::UTF8_CHARSET.

Referenced by Botan::ASN1_EAC_String::ASN1_EAC_String(), Botan::ASN1_String::ASN1_String(), Botan::ASN1_EAC_String::decode_from(), Botan::X509_Time::decode_from(), Botan::ASN1_String::decode_from(), Botan::AlternativeName::decode_from(), Botan::X509_Time::encode_into(), Botan::ASN1_String::encode_into(), Botan::ASN1_EAC_String::value(), and Botan::ASN1_String::value().

00105    {
00106    if(to == LOCAL_CHARSET)
00107       to = LATIN1_CHARSET;
00108    if(from == LOCAL_CHARSET)
00109       from = LATIN1_CHARSET;
00110 
00111    if(to == from)
00112       return str;
00113 
00114    if(from == LATIN1_CHARSET && to == UTF8_CHARSET)
00115       return latin1_to_utf8(str);
00116    if(from == UTF8_CHARSET && to == LATIN1_CHARSET)
00117       return utf8_to_latin1(str);
00118    if(from == UCS2_CHARSET && to == LATIN1_CHARSET)
00119       return ucs2_to_latin1(str);
00120 
00121    throw Invalid_Argument("Unknown transcoding operation from " +
00122                           to_string(from) + " to " + to_string(to));
00123    }


Generated on Tue Jun 29 08:56:47 2010 for Botan by  doxygen 1.5.8