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,2006 by L.Johnson & J.van der Zijp.  All Rights Reserved.  *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (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 GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXTextCodec.h,v 1.30 2006/01/22 17:58:11 fox Exp $                       *
00023 ********************************************************************************/
00024 #ifndef FXTEXTCODEC_H
00025 #define FXTEXTCODEC_H
00026 
00027 #ifndef FXOBJECT_H
00028 #include "FXObject.h"
00029 #endif
00030 
00031 
00032 namespace FX {
00033 
00034 
00035 /**
00036  * Abstract base class for a stateless coder/decoder.
00037  */
00038 class FXAPI FXTextCodec : public FXObject {
00039   FXDECLARE_ABSTRACT(FXTextCodec)
00040 public:
00041 
00042   /// Construct text codec
00043   FXTextCodec(){}
00044 
00045 
00046   /// Convert utf8 to single wide character
00047   static FXint utf2wc(FXwchar& wc,const FXchar* src,FXint nsrc);
00048 
00049   /// Convert utf16 to single wide character
00050   static FXint utf2wc(FXwchar& wc,const FXnchar* src,FXint nsrc);
00051 
00052   /// Convert utf32 to single wide character
00053   static FXint utf2wc(FXwchar& wc,const FXwchar* src,FXint nsrc);
00054 
00055 
00056   /// Convert single wide character to utf8
00057   static FXint wc2utf(FXchar* dst,FXint ndst,FXwchar wc);
00058 
00059   /// Convert single wide character to utf16
00060   static FXint wc2utf(FXnchar* dst,FXint ndst,FXwchar wc);
00061 
00062   /// Convert single wide character to utf32
00063   static FXint wc2utf(FXwchar* dst,FXint ndst,FXwchar wc);
00064 
00065 
00066   /// Count utf8 bytes needed to convert multi-byte characters from src
00067   virtual FXint mb2utflen(const FXchar* src,FXint nsrc) const;
00068 
00069   /// Count utf8 bytes needed to convert multi-byte characters from src
00070   FXint mb2utflen(const FXString& src) const;
00071 
00072   /// Convert multi-byte characters from src to utf8 characters at dst
00073   virtual FXint mb2utf(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const;
00074 
00075   /// Convert multi-byte characters from src to utf8 characters at dst
00076   FXint mb2utf(FXchar* dst,FXint ndst,const FXchar* src) const;
00077 
00078   /// Convert multi-byte characters from src to utf8 characters at dst
00079   FXint mb2utf(FXchar* dst,FXint ndst,const FXString& src) const;
00080 
00081   /// Convert multi-byte characters from src to utf8 string
00082   FXString mb2utf(const FXchar* src,FXint nsrc) const;
00083 
00084   /// Convert multi-byte characters from src to utf8 string
00085   FXString mb2utf(const FXchar* src) const;
00086 
00087   /// Convert multi-byte string to utf8 string
00088   FXString mb2utf(const FXString& src) const;
00089 
00090   /// Convert multi-byte characters from src to single wide character
00091   virtual FXint mb2wc(FXwchar& wc,const FXchar* src,FXint nsrc) const;
00092 
00093 
00094 
00095   /// Count multi-byte characters characters needed to convert utf8 from src
00096   virtual FXint utf2mblen(const FXchar* src,FXint nsrc) const;
00097 
00098   /// Count multi-byte characters characters needed to convert utf8 from src
00099   virtual FXint utf2mblen(const FXString& src) const;
00100 
00101   /// Convert utf8 characters at src to multi-byte characters at dst
00102   virtual FXint utf2mb(FXchar* dst,FXint ndst,const FXchar* src,FXint nsrc) const;
00103 
00104   /// Convert utf8 characters at src to multi-byte characters at dst
00105   FXint utf2mb(FXchar* dst,FXint ndst,const FXchar* src) const;
00106 
00107   /// Convert utf8 characters at src to multi-byte characters at dst
00108   FXint utf2mb(FXchar* dst,FXint ndst,const FXString& src) const;
00109 
00110   /// Convert utf8 characters at src to multi-byte string
00111   FXString utf2mb(const FXchar* src,FXint nsrc) const;
00112 
00113   /// Convert utf8 characters at src to multi-byte string
00114   FXString utf2mb(const FXchar* src) const;
00115 
00116   /// Convert utf8 string to multi-byte string
00117   FXString utf2mb(const FXString& src) const;
00118 
00119   /// Convert single wide character to multi-byte characters at dst
00120   virtual FXint wc2mb(FXchar* dst,FXint ndst,FXwchar wc) const;
00121 
00122 
00123   /**
00124   * Return the Management Information Base (MIBenum) for the character set.
00125   */
00126   virtual FXint mibEnum() const = 0;
00127 
00128   /**
00129   * Return name of the codec.
00130   */
00131   virtual const FXchar* name() const = 0;
00132 
00133   /**
00134   * Return the IANA mime name for this codec; this is used for example
00135   * as "text/utf-8" in drag and drop protocols.
00136   */
00137   virtual const FXchar* mimeName() const = 0;
00138 
00139   /**
00140   * Return NULL-terminated list of aliases for this codec.
00141   */
00142   virtual const FXchar* const* aliases() const = 0;
00143 
00144   /// Destruct codec
00145   virtual ~FXTextCodec(){}
00146   };
00147 
00148 }
00149 
00150 #endif

Copyright © 1997-2005 Jeroen van der Zijp