Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXTextCodec.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * U n i c o d e T e x t C o d e c *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2002,2006 by L.Johnson & J.van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXTextCodec.h,v 1.30 2006/01/22 17:58:11 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXTEXTCODEC_H
25 #define FXTEXTCODEC_H
26 
27 #ifndef FXOBJECT_H
28 #include "FXObject.h"
29 #endif
30 
31 
32 namespace FX {
33 
34 
35 /**
36  * Abstract base class for a stateless coder/decoder.
37  */
38 class FXAPI FXTextCodec : public FXObject {
40 public:
41 
42  /// Construct text codec
44 
45 
46  /// Convert utf8 to single wide character
47  static FXint utf2wc(FXwchar& wc,const FXchar* src,FXint nsrc);
48 
49  /// Convert utf16 to single wide character
50  static FXint utf2wc(FXwchar& wc,const FXnchar* src,FXint nsrc);
51 
52  /// Convert utf32 to single wide character
53  static FXint utf2wc(FXwchar& wc,const FXwchar* src,FXint nsrc);
54 
55 
56  /// Convert single wide character to utf8
57  static FXint wc2utf(FXchar* dst,FXint ndst,FXwchar wc);
58 
59  /// Convert single wide character to utf16
60  static FXint wc2utf(FXnchar* dst,FXint ndst,FXwchar wc);
61 
62  /// Convert single wide character to utf32
63  static FXint wc2utf(FXwchar* dst,FXint ndst,FXwchar wc);
64 
65 
66  /// Count utf8 bytes needed to convert multi-byte characters from src
67  virtual FXint mb2utflen(const FXchar* src,FXint nsrc) const;
68 
69  /// Count utf8 bytes needed to convert multi-byte characters from src
70  FXint mb2utflen(const FXString& src) const;
71 
72  /// Convert multi-byte characters from src to utf8 characters at dst
73  virtual FXint mb2utf(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const;
74 
75  /// Convert multi-byte characters from src to utf8 characters at dst
76  FXint mb2utf(FXchar* dst,FXint ndst,const FXchar* src) const;
77 
78  /// Convert multi-byte characters from src to utf8 characters at dst
79  FXint mb2utf(FXchar* dst,FXint ndst,const FXString& src) const;
80 
81  /// Convert multi-byte characters from src to utf8 string
82  FXString mb2utf(const FXchar* src,FXint nsrc) const;
83 
84  /// Convert multi-byte characters from src to utf8 string
85  FXString mb2utf(const FXchar* src) const;
86 
87  /// Convert multi-byte string to utf8 string
88  FXString mb2utf(const FXString& src) const;
89 
90  /// Convert multi-byte characters from src to single wide character
91  virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const;
92 
93 
94 
95  /// Count multi-byte characters characters needed to convert utf8 from src
96  virtual FXint utf2mblen(const FXchar* src,FXint nsrc) const;
97 
98  /// Count multi-byte characters characters needed to convert utf8 from src
99  virtual FXint utf2mblen(const FXString& src) const;
100 
101  /// Convert utf8 characters at src to multi-byte characters at dst
102  virtual FXint utf2mb(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const;
103 
104  /// Convert utf8 characters at src to multi-byte characters at dst
105  FXint utf2mb(FXchar* dst,FXint ndst,const FXchar* src) const;
106 
107  /// Convert utf8 characters at src to multi-byte characters at dst
108  FXint utf2mb(FXchar* dst,FXint ndst,const FXString& src) const;
109 
110  /// Convert utf8 characters at src to multi-byte string
111  FXString utf2mb(const FXchar* src,FXint nsrc) const;
112 
113  /// Convert utf8 characters at src to multi-byte string
114  FXString utf2mb(const FXchar* src) const;
115 
116  /// Convert utf8 string to multi-byte string
117  FXString utf2mb(const FXString& src) const;
118 
119  /// Convert single wide character to multi-byte characters at dst
120  virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const;
121 
122 
123  /**
124  * Return the Management Information Base (MIBenum) for the character set.
125  */
126  virtual FXint mibEnum() const = 0;
127 
128  /**
129  * Return name of the codec.
130  */
131  virtual const FXchar* name() const = 0;
132 
133  /**
134  * Return the IANA mime name for this codec; this is used for example
135  * as "text/utf-8" in drag and drop protocols.
136  */
137  virtual const FXchar* mimeName() const = 0;
138 
139  /**
140  * Return NULL-terminated list of aliases for this codec.
141  */
142  virtual const FXchar* const* aliases() const = 0;
143 
144  /// Destruct codec
145  virtual ~FXTextCodec(){}
146  };
147 
148 }
149 
150 #endif
Abstract base class for a stateless coder/decoder.
Definition: FXTextCodec.h:38
char FXchar
Definition: fxdefs.h:387
unsigned short FXnchar
Definition: fxdefs.h:412
#define FXAPI
Definition: fxdefs.h:122
#define FXDECLARE_ABSTRACT(classname)
Macro to set up abstract class declaration.
Definition: FXObject.h:114
FXString name(const FXString &file)
Return name and extension part of the path name.
wchar_t FXwchar
Definition: fxdefs.h:411
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
virtual ~FXTextCodec()
Destruct codec.
Definition: FXTextCodec.h:145
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
FXTextCodec()
Construct text codec.
Definition: FXTextCodec.h:43
FXwchar wc(const FXchar *ptr)
Return wide character from utf8 string at ptr.
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp