3 //=========================================================================
5 * @file UTF16_Encoding_Converter.h
7 * $Id: UTF16_Encoding_Converter.h 80826 2008-03-04 14:51:23Z wotte $
9 * This class contains declarations for methods that convert between
10 * UTF-16 (both BE and LE) and UTF-8
12 * @author Chad Elliott <elliott_c@ociweb.com>
14 //=========================================================================
16 #ifndef ACE_UTF16_ENCODING_CONVERTER_H
17 #define ACE_UTF16_ENCODING_CONVERTER_H
19 #include /**/ "ace/pre.h"
21 #include "ace/Encoding_Converter.h"
23 #if defined (ACE_USES_WCHAR)
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
26 /** Convert from UTF-16 to UTF-8 and from UTF-8 to UTF-16.
27 * This class implements the ACE_Encoding_Converter interface.
29 class ACE_UTF16_Encoding_Converter
: public ACE_Encoding_Converter
32 /// The swap parameter determines whether we need to swap byte order on
33 /// the stream as each word is pulled off when converting to UTF-8.
34 ACE_UTF16_Encoding_Converter (bool swap
= false);
36 /// This is a do nothing destructor.
37 virtual ~ACE_UTF16_Encoding_Converter (void);
39 /// Convert the source from UTF-16 to UTF-8 and store it in the
40 /// provided target buffer.
41 virtual Result
to_utf8 (const void* source
,
47 /// Convert the UTF-8 source into a UTF-16 encoding and store it
48 /// in the provided target buffer.
49 virtual Result
from_utf8 (const ACE_Byte
* source
,
55 /// This factory helper method determines if the source stream is UTF-16
56 /// encoded. If it is, allocate an ACE_UTF16_Encoding_Converter and
57 /// return it. The caller then owns the allocated object.
58 static ACE_UTF16_Encoding_Converter
* encoded (const ACE_Byte
* source
,
62 /// Determines if the source buffer is legal UTF-8
63 bool is_legal_utf8 (const ACE_Byte
* source
,
66 static ACE_UINT32
get_UNI_SUR_HIGH_START (void);
67 static ACE_UINT32
get_UNI_SUR_LOW_END (void);
68 static ACE_UINT32
get_UNI_REPLACEMENT_CHAR (void);
69 static const ACE_Byte
* get_first_byte_mark (void);
70 static const ACE_Byte
* get_trailing_bytes_for_utf8 (void);
71 static const ACE_UINT32
* get_offsets_from_utf8 (void);
76 ACE_END_VERSIONED_NAMESPACE_DECL
78 #if defined (__ACE_INLINE__)
79 #include "ace/UTF16_Encoding_Converter.inl"
80 #endif /* __ACE_INLINE__ */
82 #endif /* ACE_USES_WCHAR */
84 #include /**/ "ace/post.h"
86 #endif /* ACE_UTF16_ENCODING_CONVERTER_H */