E-MailRelay
src
glib
gconvert.cpp
Go to the documentation of this file.
1
//
2
// Copyright (C) 2001-2021 Graeme Walker <graeme_walker@users.sourceforge.net>
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
// ===
17
///
18
/// \file gconvert.cpp
19
///
20
21
#include "gdef.h"
22
#include "
gconvert.h
"
23
24
void
G::Convert::convert
(
G::Convert::utf8
& out_ ,
const
G::Convert::utf8
& s )
25
{
26
out_ = s ;
// utf8 -> utf8
27
}
28
29
void
G::Convert::convert
( std::string & out_ ,
const
std::string & s )
30
{
31
out_ = s ;
// ansi -> ansi
32
}
33
34
void
G::Convert::convert
( std::string & out_ ,
const
std::string & s ,
const
ThrowOnError
& )
35
{
36
out_ = s ;
37
}
38
39
void
G::Convert::convert
( std::wstring & out_ ,
const
std::wstring & s )
40
{
41
out_ = s ;
42
}
43
44
void
G::Convert::convert
(
G::Convert::utf8
& out_ ,
const
std::string & s )
45
{
46
out_ =
utf8
(narrow(widen(s,
false
),
true
)) ;
// ansi -> utf16 -> utf8
47
}
48
49
void
G::Convert::convert
(
G::Convert::utf8
& out_ ,
const
std::wstring & s )
50
{
51
out_ =
utf8
(narrow(s,
true
)) ;
// utf16 -> utf8
52
}
53
54
void
G::Convert::convert
( std::string & out_ ,
const
G::Convert::utf8
& s ,
const
ThrowOnError
& e )
55
{
56
out_ = narrow(widen(s.s,
true
),
false
,e.context) ;
// utf8 -> utf16 -> ansi
57
}
58
59
void
G::Convert::convert
( std::string & out_ ,
const
std::wstring & s ,
const
ThrowOnError
& e )
60
{
61
out_ = narrow(s,
false
,e.context) ;
62
}
63
64
void
G::Convert::convert
( std::wstring & out_ ,
const
std::string & s )
65
{
66
out_ = widen(s,
false
) ;
67
}
68
69
void
G::Convert::convert
( std::wstring & out_ ,
const
G::Convert::utf8
& s )
70
{
71
out_ = widen(s.s,
true
) ;
72
}
73
G::Convert::convert
static void convert(utf8 &utf_out, const std::string &in_)
Converts between string types/encodings: ansi to utf8.
Definition:
gconvert.cpp:44
gconvert.h
G::Convert::ThrowOnError
Holds context information which convert() adds to the exception when it fails.
Definition:
gconvert.h:75
G::Convert::utf8
A string wrapper that indicates UTF-8 encoding.
Definition:
gconvert.h:68
Generated by
1.9.3