3 //=========================================================================
5 * @file UTF16_Encoding_Converter.h
7 * This class contains declarations for methods that convert between
8 * UTF-16 (both BE and LE) and UTF-8
10 * @author Chad Elliott <elliott_c@ociweb.com>
12 //=========================================================================
14 #ifndef ACE_UTF16_ENCODING_CONVERTER_H
15 #define ACE_UTF16_ENCODING_CONVERTER_H
17 #include /**/ "ace/pre.h"
19 #include "ace/Encoding_Converter.h"
21 #if defined (ACE_USES_WCHAR)
22 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
24 /** Convert from UTF-16 to UTF-8 and from UTF-8 to UTF-16.
25 * This class implements the ACE_Encoding_Converter interface.
27 class ACE_UTF16_Encoding_Converter
: public ACE_Encoding_Converter
30 /// The swap parameter determines whether we need to swap byte order on
31 /// the stream as each word is pulled off when converting to UTF-8.
32 ACE_UTF16_Encoding_Converter (bool swap
= false);
34 /// This is a do nothing destructor.
35 virtual ~ACE_UTF16_Encoding_Converter ();
37 /// Convert the source from UTF-16 to UTF-8 and store it in the
38 /// provided target buffer.
39 virtual Result
to_utf8 (const void* source
,
45 /// Convert the UTF-8 source into a UTF-16 encoding and store it
46 /// in the provided target buffer.
47 virtual Result
from_utf8 (const ACE_Byte
* source
,
53 /// This factory helper method determines if the source stream is UTF-16
54 /// encoded. If it is, allocate an ACE_UTF16_Encoding_Converter and
55 /// return it. The caller then owns the allocated object.
56 static ACE_UTF16_Encoding_Converter
* encoded (const ACE_Byte
* source
,
60 /// Determines if the source buffer is legal UTF-8
61 bool is_legal_utf8 (const ACE_Byte
* source
,
64 static ACE_UINT32
get_UNI_SUR_HIGH_START ();
65 static ACE_UINT32
get_UNI_SUR_LOW_END ();
66 static ACE_UINT32
get_UNI_REPLACEMENT_CHAR ();
67 static const ACE_Byte
* get_first_byte_mark ();
68 static const ACE_Byte
* get_trailing_bytes_for_utf8 ();
69 static const ACE_UINT32
* get_offsets_from_utf8 ();
74 ACE_END_VERSIONED_NAMESPACE_DECL
76 #if defined (__ACE_INLINE__)
77 #include "ace/UTF16_Encoding_Converter.inl"
78 #endif /* __ACE_INLINE__ */
80 #endif /* ACE_USES_WCHAR */
82 #include /**/ "ace/post.h"
84 #endif /* ACE_UTF16_ENCODING_CONVERTER_H */