HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_CharSetUtils.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_CharSetUtils.h (UT Library, C++)
7  *
8  * COMMENTS:
9  * Utilities for encoding, decoding, and converting text
10  * from, to, and between character sets and other encodings.
11  */
12 
13 #ifndef __UT_CharSetUtils__
14 #define __UT_CharSetUtils__
15 
16 #include "UT_API.h"
17 
18 #include <SYS/SYS_Types.h>
19 
20 class UT_String;
21 class UT_StringHolder;
22 class UT_WorkBuffer;
23 
24 
26 {
27 public:
28  // The encoding of the source code strings (ie, the char* stuff)
29  // Currently it specifies ISO-9959-1 (Latin 1) char set.
30  static const char * const SRC_CODE_ENCODING;
31 
32  // The encoding used in the XML file. Currently it specifies UTF-8.
33  static const char * const XML_ENCODING;
34 
35  /// Conversion method from the source encoding to UTF-8 Unicode encoding.
36  /// src_str - the input string bytestream in the src_encoding
37  /// out_str - the output string bytesream in the UTF-8 encoding.
38  /// src_encoding - always Latin 1
39  //
40  /// Returns true if ok, false otherwise.
41  static bool encodeUTF8( const char * src_str,
42  UT_WorkBuffer & out_str );
43 
44  /// Conversion method from the source encoding of UTF-8 to the encoding
45  /// specified by the out_encoding.
46  /// src_str - the input string bytestream in the UTF-8 encoding.
47  /// out_str - the output string bytesream in the out_encoding.
48  /// out_encoding - always Latin 1
49  //
50  /// Returns true if ok, false otherwise.
51  /// @{
52  static bool decodeUTF8( const char * src_str,
53  UT_WorkBuffer & out_str );
54  static bool decodeUTF8( const char * src_str,
55  UT_String & out_str );
56  static bool decodeUTF8( const char * src_str,
57  UT_StringHolder & out_str );
58  /// @}
59 
60  /// As above, but decoding only the first 'src_len' bytes of src_str,
61  /// which therefore does not have to be NUL terminated unless 'src_len'
62  /// is negative.
63  /// @{
64  static bool decodeUTF8( const char * src_str, exint src_len,
65  UT_WorkBuffer & out_str );
66  static bool decodeUTF8( const char * src_str, exint src_len,
67  UT_String & out_str );
68  /// @}
69 };
70 
71 #endif
72 
int64 exint
Definition: SYS_Types.h:125
static const char *const SRC_CODE_ENCODING
#define UT_API
Definition: UT_API.h:14
static const char *const XML_ENCODING