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

FXTextCodec.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                   U n i c o d e   T e x t   C o d e c                         *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2002,2010 by L.Johnson & J.van der Zijp.  All Rights Reserved.  *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXTEXTCODEC_H
00022 #define FXTEXTCODEC_H
00023 
00024 #ifndef FXOBJECT_H
00025 #include "FXObject.h"
00026 #endif
00027 
00028 
00029 namespace FX {
00030 
00031 
00032 /**
00033  * Abstract base class for a stateless coder/decoder.
00034  */
00035 class FXAPI FXTextCodec : public FXObject {
00036   FXDECLARE_ABSTRACT(FXTextCodec)
00037 public:
00038 
00039   /// Construct text codec
00040   FXTextCodec(){}
00041 
00042 
00043   /// Convert utf8 to single wide character
00044   static FXint utf2wc(FXwchar& wc,const FXchar* src,FXint nsrc);
00045 
00046   /// Convert utf16 to single wide character
00047   static FXint utf2wc(FXwchar& wc,const FXnchar* src,FXint nsrc);
00048 
00049   /// Convert utf32 to single wide character
00050   static FXint utf2wc(FXwchar& wc,const FXwchar* src,FXint nsrc);
00051 
00052 
00053   /// Convert single wide character to utf8
00054   static FXint wc2utf(FXchar* dst,FXint ndst,FXwchar wc);
00055 
00056   /// Convert single wide character to utf16
00057   static FXint wc2utf(FXnchar* dst,FXint ndst,FXwchar wc);
00058 
00059   /// Convert single wide character to utf32
00060   static FXint wc2utf(FXwchar* dst,FXint ndst,FXwchar wc);
00061 
00062 
00063   /// Count utf8 bytes needed to convert multi-byte characters from src
00064   virtual FXint mb2utflen(const FXchar* src,FXint nsrc) const;
00065 
00066   /// Count utf8 bytes needed to convert multi-byte characters from src
00067   FXint mb2utflen(const FXString& src) const;
00068 
00069   /// Convert multi-byte characters from src to utf8 characters at dst
00070   virtual FXint mb2utf(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const;
00071 
00072   /// Convert multi-byte characters from src to utf8 characters at dst
00073   FXint mb2utf(FXchar* dst,FXint ndst,const FXchar* src) const;
00074 
00075   /// Convert multi-byte characters from src to utf8 characters at dst
00076   FXint mb2utf(FXchar* dst,FXint ndst,const FXString& src) const;
00077 
00078   /// Convert multi-byte characters from src to utf8 string
00079   FXString mb2utf(const FXchar* src,FXint nsrc) const;
00080 
00081   /// Convert multi-byte characters from src to utf8 string
00082   FXString mb2utf(const FXchar* src) const;
00083 
00084   /// Convert multi-byte string to utf8 string
00085   FXString mb2utf(const FXString& src) const;
00086 
00087   /// Convert multi-byte characters from src to single wide character
00088   virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const;
00089 
00090 
00091 
00092   /// Count multi-byte characters characters needed to convert utf8 from src
00093   virtual FXint utf2mblen(const FXchar* src,FXint nsrc) const;
00094 
00095   /// Count multi-byte characters characters needed to convert utf8 from src
00096   virtual FXint utf2mblen(const FXString& src) const;
00097 
00098   /// Convert utf8 characters at src to multi-byte characters at dst
00099   virtual FXint utf2mb(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const;
00100 
00101   /// Convert utf8 characters at src to multi-byte characters at dst
00102   FXint utf2mb(FXchar* dst,FXint ndst,const FXchar* src) const;
00103 
00104   /// Convert utf8 characters at src to multi-byte characters at dst
00105   FXint utf2mb(FXchar* dst,FXint ndst,const FXString& src) const;
00106 
00107   /// Convert utf8 characters at src to multi-byte string
00108   FXString utf2mb(const FXchar* src,FXint nsrc) const;
00109 
00110   /// Convert utf8 characters at src to multi-byte string
00111   FXString utf2mb(const FXchar* src) const;
00112 
00113   /// Convert utf8 string to multi-byte string
00114   FXString utf2mb(const FXString& src) const;
00115 
00116   /// Convert single wide character to multi-byte characters at dst
00117   virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const;
00118 
00119 
00120   /**
00121   * Return the Management Information Base (MIBenum) for the character set.
00122   */
00123   virtual FXint mibEnum() const = 0;
00124 
00125   /**
00126   * Return name of the codec.
00127   */
00128   virtual const FXchar* name() const = 0;
00129 
00130   /**
00131   * Return the IANA mime name for this codec; this is used for example
00132   * as "text/utf-8" in drag and drop protocols.
00133   */
00134   virtual const FXchar* mimeName() const = 0;
00135 
00136   /**
00137   * Return NULL-terminated list of aliases for this codec.
00138   */
00139   virtual const FXchar* const* aliases() const = 0;
00140 
00141   /// Destruct codec
00142   virtual ~FXTextCodec(){}
00143   };
00144 
00145 }
00146 
00147 #endif

Copyright © 1997-2010 Jeroen van der Zijp