3 /// iconv wrapper class for Windows
7 Copyright (C) 2008-2011, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
32 //////////////////////////////////////////////////////////////////////////////
33 // IConvHandlePrivate class
34 class IConvHandlePrivate
39 //////////////////////////////////////////////////////////////////////////////
42 IConvHandle::IConvHandle(const char *fromcode
,
44 bool throw_on_conv_err
)
45 : m_priv( new IConvHandlePrivate
)
46 , m_throw_on_conv_err(throw_on_conv_err
)
50 IConvHandle::IConvHandle(const char *fromcode
,
52 bool throw_on_conv_err
)
53 : m_priv( new IConvHandlePrivate
)
54 , m_throw_on_conv_err(throw_on_conv_err
)
58 IConvHandle::IConvHandle(const IConverter
&ic
,
60 bool throw_on_conv_err
)
61 : m_priv( new IConvHandlePrivate
)
62 , m_throw_on_conv_err(throw_on_conv_err
)
66 IConvHandle::~IConvHandle()
70 std::string
IConvHandle::Convert(Data
&tmp
, const std::string
&str
) const
72 // FIXME - need to add Windows support
77 //////////////////////////////////////////////////////////////////////////////
80 IConverter::IConverter(const char *tocode
, bool throw_on_conv_err
)
81 : m_from(BLACKBERRY_CHARSET
, tocode
, throw_on_conv_err
)
82 , m_to(tocode
, BLACKBERRY_CHARSET
, throw_on_conv_err
)
87 IConverter::~IConverter()
91 std::string
IConverter::FromBB(const std::string
&str
) const
93 return m_from
.Convert(m_buffer
, str
);
96 std::string
IConverter::ToBB(const std::string
&str
) const
98 return m_to
.Convert(m_buffer
, str
);
101 std::string
IConverter::Convert(const IConvHandle
&custom
, const std::string
&str
) const
103 return custom
.Convert(m_buffer
, str
);