18#ifndef _LOG4CXX_HELPERS_TRANSCODER_H
19#define _LOG4CXX_HELPERS_TRANSCODER_H
74 static unsigned int decode(
const std::string& in,
75 std::string::const_iterator& iter);
82 static void encode(
unsigned int ch, std::string& dst);
107#if LOG4CXX_WCHAR_T_API || LOG4CXX_LOGCHAR_IS_WCHAR_T || defined(WIN32) || defined(_WIN32)
119 static unsigned int decode(
const std::wstring& in,
120 std::wstring::const_iterator& iter);
127 static void encode(
unsigned int ch, std::wstring& dst);
132#if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API || LOG4CXX_LOGCHAR_IS_UNICHAR
143 static unsigned int decode(
const std::basic_string<UniChar>& in,
144 std::basic_string<UniChar>::const_iterator& iter);
151 static void encode(
unsigned int ch, std::basic_string<UniChar>& dst);
155#if LOG4CXX_CFSTRING_API
160 enum { LOSSCHAR = 0x3F };
185 enum { BUFSIZE = 256 };
186 static size_t encodeUTF8(
unsigned int ch,
char* dst);
187 static size_t encodeUTF16BE(
unsigned int ch,
char* dst);
188 static size_t encodeUTF16LE(
unsigned int ch,
char* dst);
194#define LOG4CXX_ENCODE_CHAR(var, src) \
196 log4cxx::helpers::Transcoder::encode(src, var)
198#define LOG4CXX_DECODE_CHAR(var, src) \
199 log4cxx::LogString var; \
200 log4cxx::helpers::Transcoder::decode(src, var)
202#define LOG4CXX_DECODE_CFSTRING(var, src) \
203 log4cxx::LogString var; \
204 log4cxx::helpers::Transcoder::decode(src, var)
206#define LOG4CXX_ENCODE_CFSTRING(var, src) \
207 CFStringRef var = log4cxx::helpers::Transcoder::encode(src)
210#if LOG4CXX_LOGCHAR_IS_WCHAR
212#define LOG4CXX_ENCODE_WCHAR(var, src) \
213 const std::wstring& var = src
215#define LOG4CXX_DECODE_WCHAR(var, src) \
216 const log4cxx::LogString& var = src
220#define LOG4CXX_ENCODE_WCHAR(var, src) \
222 log4cxx::helpers::Transcoder::encode(src, var)
224#define LOG4CXX_DECODE_WCHAR(var, src) \
225 log4cxx::LogString var; \
226 log4cxx::helpers::Transcoder::decode(src, var)
230#if LOG4CXX_LOGCHAR_IS_UNICHAR
232#define LOG4CXX_ENCODE_UNICHAR(var, src) \
233 const std::basic_string<UniChar>& var = src
235#define LOG4CXX_DECODE_UNICHAR(var, src) \
236 const log4cxx::LogString& var = src
240#define LOG4CXX_ENCODE_UNICHAR(var, src) \
241 std::basic_string<UniChar> var; \
242 log4cxx::helpers::Transcoder::encode(src, var)
244#define LOG4CXX_DECODE_UNICHAR(var, src) \
245 log4cxx::LogString var; \
246 log4cxx::helpers::Transcoder::decode(src, var)
A byte buffer.
Definition: bytebuffer.h:34
Simple transcoder for converting between external char and wchar_t strings and internal strings.
Definition: transcoder.h:37
static void decode(const std::basic_string< UniChar > &src, LogString &dst)
static unsigned int decode(const std::string &in, std::string::const_iterator &iter)
Decodes next character from a UTF-8 string.
static void encode(const LogString &src, std::basic_string< UniChar > &dst)
static void encodeUTF16LE(unsigned int sv, ByteBuffer &dst)
Append UCS-4 code point to a byte buffer as UTF-16LE.
static void encodeUTF16BE(unsigned int sv, ByteBuffer &dst)
Append UCS-4 code point to a byte buffer as UTF-16BE.
static void decode(const std::wstring &src, LogString &dst)
static wchar_t * wencode(const LogString &src, log4cxx::helpers::Pool &p)
static void encode(const LogString &src, std::wstring &dst)
static void encode(const LogString &src, std::string &dst)
Appends a LogString to a string in the current code-page.
static void encodeUTF8(const LogString &src, std::string &dst)
Converts the LogString to a UTF-8 string.
static char * encode(const LogString &src, log4cxx::helpers::Pool &p)
Encodes the specified LogString to the current character set.
static unsigned int decode(const std::wstring &in, std::wstring::const_iterator &iter)
Decodes next character from a wstring.
static std::string encodeCharsetName(const LogString &charsetName)
Encodes a charset name in the default encoding without using a CharsetEncoder (which could trigger re...
static char * encodeUTF8(const LogString &src, log4cxx::helpers::Pool &p)
Converts the LogString to a UTF-8 string.
static CFStringRef encode(const LogString &src)
static void decodeUTF8(const std::string &src, LogString &dst)
Appends this specified string of UTF-8 characters to LogString.
static unsigned int decode(const std::basic_string< UniChar > &in, std::basic_string< UniChar >::const_iterator &iter)
Decodes next character from a UniChar string.
static void encode(unsigned int ch, std::basic_string< UniChar > &dst)
Appends UCS-4 value to a UTF-8 string.
static logchar decode(char v)
Returns a logchar value given a character literal in the ASCII charset.
static void encode(unsigned int ch, std::wstring &dst)
Appends UCS-4 value to a UTF-8 string.
static LogString decode(const char *v)
Returns a LogString given a string literal in the ASCII charset.
static void encode(unsigned int ch, std::string &dst)
Appends UCS-4 value to a UTF-8 string.
static void decode(const CFStringRef &src, LogString &dst)
static void decode(const std::string &src, LogString &dst)
Appends string in the current code-page to a LogString.
static void encodeUTF8(unsigned int sv, ByteBuffer &dst)
Append UCS-4 code point to a byte buffer as UTF-8.
const struct __CFString * CFStringRef
Definition: logstring.h:30
Definition: configuration.h:25
std::basic_string< logchar > LogString
Definition: logstring.h:60