Botan  2.11.0
Crypto and TLS for C++11
Functions | Variables
Botan::Charset Namespace Reference

Functions

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

Variables

bool char y
 

Function Documentation

◆ BOTAN_PUBLIC_API()

char Botan::Charset::BOTAN_PUBLIC_API ( ,
 
)

◆ caseless_cmp()

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

Definition at line 275 of file charset.cpp.

276  {
277  return (std::tolower(static_cast<unsigned char>(a)) ==
278  std::tolower(static_cast<unsigned char>(b)));
279  }
bool const OID & b
Definition: asn1_oid.h:109
size_t const BigInt & a
Definition: numthry.h:111

References Botan::a, and Botan::b.

Referenced by Botan::x500_name_cmp().

◆ char2digit()

uint8_t Botan::Charset::char2digit ( char  c)

Definition at line 231 of file charset.cpp.

232  {
233  switch(c)
234  {
235  case '0': return 0;
236  case '1': return 1;
237  case '2': return 2;
238  case '3': return 3;
239  case '4': return 4;
240  case '5': return 5;
241  case '6': return 6;
242  case '7': return 7;
243  case '8': return 8;
244  case '9': return 9;
245  }
246 
247  throw Invalid_Argument("char2digit: Input is not a digit character");
248  }
BigInt const BigInt const BigInt & c
Definition: numthry.h:25

References Botan::c.

◆ digit2char()

char Botan::Charset::digit2char ( uint8_t  b)

Definition at line 253 of file charset.cpp.

254  {
255  switch(b)
256  {
257  case 0: return '0';
258  case 1: return '1';
259  case 2: return '2';
260  case 3: return '3';
261  case 4: return '4';
262  case 5: return '5';
263  case 6: return '6';
264  case 7: return '7';
265  case 8: return '8';
266  case 9: return '9';
267  }
268 
269  throw Invalid_Argument("digit2char: Input is not a digit");
270  }
bool const OID & b
Definition: asn1_oid.h:109

References Botan::b.

◆ is_digit()

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

Definition at line 210 of file charset.cpp.

211  {
212  if(c == '0' || c == '1' || c == '2' || c == '3' || c == '4' ||
213  c == '5' || c == '6' || c == '7' || c == '8' || c == '9')
214  return true;
215  return false;
216  }
BigInt const BigInt const BigInt & c
Definition: numthry.h:25

References Botan::c.

Referenced by Botan::timespec_to_u32bit().

◆ is_space()

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

Definition at line 221 of file charset.cpp.

222  {
223  if(c == ' ' || c == '\t' || c == '\n' || c == '\r')
224  return true;
225  return false;
226  }
BigInt const BigInt const BigInt & c
Definition: numthry.h:25

References Botan::c.

Referenced by Botan::x500_name_cmp().

◆ transcode()

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

Definition at line 185 of file charset.cpp.

187  {
188  if(to == LOCAL_CHARSET)
189  to = LATIN1_CHARSET;
190  if(from == LOCAL_CHARSET)
191  from = LATIN1_CHARSET;
192 
193  if(to == from)
194  return str;
195 
196  if(from == LATIN1_CHARSET && to == UTF8_CHARSET)
197  return latin1_to_utf8(str);
198  if(from == UTF8_CHARSET && to == LATIN1_CHARSET)
199  return utf8_to_latin1(str);
200  if(from == UCS2_CHARSET && to == LATIN1_CHARSET)
201  return ucs2_to_latin1(str);
202 
203  throw Invalid_Argument("Unknown transcoding operation from " +
204  std::to_string(from) + " to " + std::to_string(to));
205  }
std::string utf8_to_latin1(const std::string &utf8)
Definition: charset.cpp:98
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:213
const char * str
Definition: ffi.h:769

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

Variable Documentation

◆ y

bool char Botan::Charset::y

Definition at line 69 of file charset.h.