Botan 3.4.0
Crypto and TLS for C&
charset.h
Go to the documentation of this file.
1/*
2* Character Set Conversions
3* (C) 1999-2007 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_CHARSET_H_
9#define BOTAN_CHARSET_H_
10
11#include <botan/types.h>
12#include <string>
13
14namespace Botan {
15
16/**
17* Convert a sequence of UCS-2 (big endian) characters to a UTF-8 string
18* This is used for ASN.1 BMPString type
19* @param ucs2 the sequence of UCS-2 characters
20* @param len length of ucs2 in bytes, must be a multiple of 2
21*/
22BOTAN_TEST_API std::string ucs2_to_utf8(const uint8_t ucs2[], size_t len);
23
24/**
25* Convert a sequence of UCS-4 (big endian) characters to a UTF-8 string
26* This is used for ASN.1 UniversalString type
27* @param ucs4 the sequence of UCS-4 characters
28* @param len length of ucs4 in bytes, must be a multiple of 4
29*/
30BOTAN_TEST_API std::string ucs4_to_utf8(const uint8_t ucs4[], size_t len);
31
32BOTAN_TEST_API std::string latin1_to_utf8(const uint8_t latin1[], size_t len);
33
34/**
35* Return a string containing 'c', quoted and possibly escaped
36*
37* This is used when creating an error message nothing an invalid character
38* in some codex (for example during hex decoding)
39*
40* Currently this function escapes tab, newlines and carriage return
41* as "\t", "\n", and "\r", and also escapes characters > 0x7F as
42* "\xHH" where HH is the hex code.
43*/
44std::string format_char_for_display(char c);
45
46} // namespace Botan
47
48#endif
#define BOTAN_TEST_API
Definition compiler.h:51
std::string format_char_for_display(char c)
Definition charset.cpp:98
std::string ucs2_to_utf8(const uint8_t ucs2[], size_t len)
Definition charset.cpp:54
std::string latin1_to_utf8(const uint8_t chars[], size_t len)
Definition charset.cpp:89
std::string ucs4_to_utf8(const uint8_t ucs4[], size_t len)
Definition charset.cpp:70