Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / ACE_wrappers / ace / UTF16_Encoding_Converter.h
blob9bdcb21a07f04da5e7155fe79b693c8483984c9b
1 // -*- C++ -*-
3 //=========================================================================
4 /**
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
31 public:
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,
42 size_t source_size,
43 ACE_Byte* target,
44 size_t target_size,
45 bool strict = true);
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,
50 size_t source_size,
51 void* target,
52 size_t target_size,
53 bool strict = true);
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,
59 size_t source_size);
61 protected:
62 /// Determines if the source buffer is legal UTF-8
63 bool is_legal_utf8 (const ACE_Byte* source,
64 size_t length) const;
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);
73 bool swap_;
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 */