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,2009 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 * $Id: FXTextCodec.h,v 1.34 2009/01/06 13:07:28 fox Exp $                       *
00022 ********************************************************************************/
00023 #ifndef FXTEXTCODEC_H
00024 #define FXTEXTCODEC_H
00025 
00026 #ifndef FXOBJECT_H
00027 #include "FXObject.h"
00028 #endif
00029 
00030 
00031 namespace FX {
00032 
00033 
00034 /**
00035  * Abstract base class for a stateless coder/decoder.
00036  */
00037 class FXAPI FXTextCodec : public FXObject {
00038   FXDECLARE_ABSTRACT(FXTextCodec)
00039 public:
00040 
00041   /// Construct text codec
00042   FXTextCodec(){}
00043 
00044 
00045   /// Convert utf8 to single wide character
00046   static FXint utf2wc(FXwchar& wc,const FXchar* src,FXint nsrc);
00047 
00048   /// Convert utf16 to single wide character
00049   static FXint utf2wc(FXwchar& wc,const FXnchar* src,FXint nsrc);
00050 
00051   /// Convert utf32 to single wide character
00052   static FXint utf2wc(FXwchar& wc,const FXwchar* src,FXint nsrc);
00053 
00054 
00055   /// Convert single wide character to utf8
00056   static FXint wc2utf(FXchar* dst,FXint ndst,FXwchar wc);
00057 
00058   /// Convert single wide character to utf16
00059   static FXint wc2utf(FXnchar* dst,FXint ndst,FXwchar wc);
00060 
00061   /// Convert single wide character to utf32
00062   static FXint wc2utf(FXwchar* dst,FXint ndst,FXwchar wc);
00063 
00064 
00065   /// Count utf8 bytes needed to convert multi-byte characters from src
00066   virtual FXint mb2utflen(const FXchar* src,FXint nsrc) const;
00067 
00068   /// Count utf8 bytes needed to convert multi-byte characters from src
00069   FXint mb2utflen(const FXString& src) const;
00070 
00071   /// Convert multi-byte characters from src to utf8 characters at dst
00072   virtual FXint mb2utf(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const;
00073 
00074   /// Convert multi-byte characters from src to utf8 characters at dst
00075   FXint mb2utf(FXchar* dst,FXint ndst,const FXchar* src) const;
00076 
00077   /// Convert multi-byte characters from src to utf8 characters at dst
00078   FXint mb2utf(FXchar* dst,FXint ndst,const FXString& src) const;
00079 
00080   /// Convert multi-byte characters from src to utf8 string
00081   FXString mb2utf(const FXchar* src,FXint nsrc) const;
00082 
00083   /// Convert multi-byte characters from src to utf8 string
00084   FXString mb2utf(const FXchar* src) const;
00085 
00086   /// Convert multi-byte string to utf8 string
00087   FXString mb2utf(const FXString& src) const;
00088 
00089   /// Convert multi-byte characters from src to single wide character
00090   virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const;
00091 
00092 
00093 
00094   /// Count multi-byte characters characters needed to convert utf8 from src
00095   virtual FXint utf2mblen(const FXchar* src,FXint nsrc) const;
00096 
00097   /// Count multi-byte characters characters needed to convert utf8 from src
00098   virtual FXint utf2mblen(const FXString& src) const;
00099 
00100   /// Convert utf8 characters at src to multi-byte characters at dst
00101   virtual FXint utf2mb(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const;
00102 
00103   /// Convert utf8 characters at src to multi-byte characters at dst
00104   FXint utf2mb(FXchar* dst,FXint ndst,const FXchar* src) const;
00105 
00106   /// Convert utf8 characters at src to multi-byte characters at dst
00107   FXint utf2mb(FXchar* dst,FXint ndst,const FXString& src) const;
00108 
00109   /// Convert utf8 characters at src to multi-byte string
00110   FXString utf2mb(const FXchar* src,FXint nsrc) const;
00111 
00112   /// Convert utf8 characters at src to multi-byte string
00113   FXString utf2mb(const FXchar* src) const;
00114 
00115   /// Convert utf8 string to multi-byte string
00116   FXString utf2mb(const FXString& src) const;
00117 
00118   /// Convert single wide character to multi-byte characters at dst
00119   virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const;
00120 
00121 
00122   /**
00123   * Return the Management Information Base (MIBenum) for the character set.
00124   */
00125   virtual FXint mibEnum() const = 0;
00126 
00127   /**
00128   * Return name of the codec.
00129   */
00130   virtual const FXchar* name() const = 0;
00131 
00132   /**
00133   * Return the IANA mime name for this codec; this is used for example
00134   * as "text/utf-8" in drag and drop protocols.
00135   */
00136   virtual const FXchar* mimeName() const = 0;
00137 
00138   /**
00139   * Return NULL-terminated list of aliases for this codec.
00140   */
00141   virtual const FXchar* const* aliases() const = 0;
00142 
00143   /// Destruct codec
00144   virtual ~FXTextCodec(){}
00145   };
00146 
00147 }
00148 
00149 #endif

Copyright © 1997-2009 Jeroen van der Zijp