cprover
unicode.h
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
10
#ifndef CPROVER_UTIL_UNICODE_H
11
#define CPROVER_UTIL_UNICODE_H
12
13
#include <algorithm>
14
#include <string>
15
#include <vector>
16
17
// we follow the ideas suggested at
18
// http://www.utf8everywhere.org/
19
20
std::string
narrow
(
const
wchar_t
*s);
21
std::wstring
widen
(
const
char
*s);
22
std::string
narrow
(
const
std::wstring &s);
23
std::wstring
widen
(
const
std::string &s);
24
25
std::string
26
utf32_native_endian_to_utf8
(
const
std::basic_string<unsigned int> &s);
27
28
std::wstring
utf8_to_utf16_native_endian
(
const
std::string &in);
29
std::string
utf16_native_endian_to_java
(
const
char16_t ch);
30
std::string
utf16_native_endian_to_java
(
const
std::wstring &in);
31
32
std::vector<std::string>
narrow_argv
(
int
argc,
const
wchar_t
**argv_wide);
33
34
template
<
typename
It>
35
std::vector<const char *>
to_c_str_array
(It b, It e)
36
{
37
// Assumes that walking the range will be faster than repeated allocation
38
std::vector<const char *> ret(std::distance(b, e) + 1,
nullptr
);
39
std::transform(b, e, std::begin(ret), [] (
const
std::string & s)
40
{
41
return
s.c_str();
42
});
43
return
ret;
44
}
45
46
#endif // CPROVER_UTIL_UNICODE_H
narrow_argv
std::vector< std::string > narrow_argv(int argc, const wchar_t **argv_wide)
Definition:
unicode.cpp:152
narrow
std::string narrow(const wchar_t *s)
Definition:
unicode.cpp:27
widen
std::wstring widen(const char *s)
Definition:
unicode.cpp:52
to_c_str_array
std::vector< const char * > to_c_str_array(It b, It e)
Definition:
unicode.h:35
utf16_native_endian_to_java
std::string utf16_native_endian_to_java(const char16_t ch)
Definition:
unicode.cpp:298
utf8_to_utf16_native_endian
std::wstring utf8_to_utf16_native_endian(const std::string &in)
Convert UTF8-encoded string to UTF-16 with architecture-native endianness.
Definition:
unicode.cpp:196
utf32_native_endian_to_utf8
std::string utf32_native_endian_to_utf8(const std::basic_string< unsigned int > &s)
Definition:
unicode.cpp:140
util
unicode.h
Generated by
1.8.17