Botan  1.11.11
Functions
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().

194  {
195  return (std::tolower(static_cast<unsigned char>(a)) ==
196  std::tolower(static_cast<unsigned char>(b)));
197  }
byte BOTAN_DLL Botan::Charset::char2digit ( char  c)

Definition at line 149 of file charset.cpp.

Referenced by Botan::BigInt::decode().

150  {
151  switch(c)
152  {
153  case '0': return 0;
154  case '1': return 1;
155  case '2': return 2;
156  case '3': return 3;
157  case '4': return 4;
158  case '5': return 5;
159  case '6': return 6;
160  case '7': return 7;
161  case '8': return 8;
162  case '9': return 9;
163  }
164 
165  throw Invalid_Argument("char2digit: Input is not a digit character");
166  }
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
char BOTAN_DLL Botan::Charset::digit2char ( byte  b)

Definition at line 171 of file charset.cpp.

Referenced by Botan::BigInt::encode().

172  {
173  switch(b)
174  {
175  case 0: return '0';
176  case 1: return '1';
177  case 2: return '2';
178  case 3: return '3';
179  case 4: return '4';
180  case 5: return '5';
181  case 6: return '6';
182  case 7: return '7';
183  case 8: return '8';
184  case 9: return '9';
185  }
186 
187  throw Invalid_Argument("digit2char: Input is not a digit");
188  }
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
bool BOTAN_DLL Botan::Charset::is_digit ( char  c)

Definition at line 128 of file charset.cpp.

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

129  {
130  if(c == '0' || c == '1' || c == '2' || c == '3' || c == '4' ||
131  c == '5' || c == '6' || c == '7' || c == '8' || c == '9')
132  return true;
133  return false;
134  }
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().

140  {
141  if(c == ' ' || c == '\t' || c == '\n' || c == '\r')
142  return true;
143  return false;
144  }
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::ASN1::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_String::decode_from(), Botan::X509_Time::decode_from(), Botan::AlternativeName::decode_from(), Botan::ASN1_EAC_String::decode_from(), Botan::ASN1_String::encode_into(), Botan::X509_Time::encode_into(), Botan::ASN1_String::value(), and Botan::ASN1_EAC_String::value().

105  {
106  if(to == LOCAL_CHARSET)
107  to = LATIN1_CHARSET;
108  if(from == LOCAL_CHARSET)
109  from = LATIN1_CHARSET;
110 
111  if(to == from)
112  return str;
113 
114  if(from == LATIN1_CHARSET && to == UTF8_CHARSET)
115  return latin1_to_utf8(str);
116  if(from == UTF8_CHARSET && to == LATIN1_CHARSET)
117  return utf8_to_latin1(str);
118  if(from == UCS2_CHARSET && to == LATIN1_CHARSET)
119  return ucs2_to_latin1(str);
120 
121  throw Invalid_Argument("Unknown transcoding operation from " +
122  std::to_string(from) + " to " + std::to_string(to));
123  }
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:46