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

FXTextCodec.h

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,2005 by Lyle Johnson. 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.8 2005/01/16 16:06:06 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXTEXTCODEC_H 00025 #define FXTEXTCODEC_H 00026 00027 00028 ////////////////////////////// UNDER DEVELOPMENT ////////////////////////////// 00029 00030 00031 namespace FX { 00032 00033 class FXTextCodecDict; 00034 00035 /** 00036 * Abstract base class for a stateless coder/decoder. 00037 */ 00038 class FXTextCodec { 00039 protected: 00040 static FXTextCodecDict* codecs; 00041 protected: 00042 FXTextCodec(){} 00043 public: 00044 00045 /** 00046 * Convert a sequence of wide characters from Unicode to the specified 00047 * 8-bit encoding. Reads at most n wide characters from src and writes 00048 * at most m bytes into dest. Returns the number of characters actually 00049 * written into dest. 00050 * 00051 * On exit, the src and dest pointers are updated to point to the next 00052 * available character (or byte) for reading (writing). 00053 */ 00054 virtual unsigned long fromUnicode(FXuchar*& dest,unsigned long m,const FXwchar*& src,unsigned long n) = 0; 00055 00056 /** 00057 * Convert a sequence of bytes in some 8-bit encoding to a sequence 00058 * of wide characters (Unicode). Reads at most n bytes from src and 00059 * writes at most m characters into dest. Returns the number of characters 00060 * actually read from src. 00061 * 00062 * On exit, the src and dest pointers are updated to point to the next 00063 * available byte (or character) for writing (reading). 00064 */ 00065 virtual unsigned long toUnicode(FXwchar*& dest,unsigned long m,const FXuchar*& src,unsigned long n) = 0; 00066 00067 /** 00068 * Return the IANA mime name for this codec; this is used for example 00069 * as "text/utf-8" in drag and drop protocols. 00070 */ 00071 virtual const FXchar* mimeName() const = 0; 00072 00073 /** 00074 * Return the Management Information Base (MIBenum) for the character set. 00075 */ 00076 virtual FXint mibEnum() const = 0; 00077 00078 /** 00079 * Register codec with this name. Returns FALSE if a different codec 00080 * has already been registered with this name, otherwise TRUE. 00081 */ 00082 static FXbool registerCodec(const FXchar* name,FXTextCodec* codec); 00083 00084 /// Return the codec associated with this name (or NULL if no match is found) 00085 static FXTextCodec* codecForName(const FXchar* name); 00086 00087 /// Destructor 00088 virtual ~FXTextCodec(){} 00089 }; 00090 00091 } 00092 00093 #endif

Copyright © 1997-2005 Jeroen van der Zijp