00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef Tanl_text_Encoding_H
00025 #define Tanl_text_Encoding_H
00026
00027
00028 #include "platform.h"
00029
00030
00031 #include <string>
00032
00033 namespace Tanl {
00034 namespace Text {
00035
00036 class Encoding
00037 {
00038 public:
00039 typedef unsigned char ID;
00040
00041 Encoding(char const* name,
00042 ID id,
00043 float averageBytesPerChar = 1.0,
00044 float maxBytesPerChar = 1.0) :
00045 name(name),id(id),
00046 averageBytesPerChar(averageBytesPerChar),
00047 maxBytesPerChar(maxBytesPerChar)
00048 { }
00049
00050 Encoding(char const* name,
00051 float averageBytesPerChar = 1.0,
00052 float maxBytesPerChar = 1.0) :
00053 name(name),
00054 averageBytesPerChar(averageBytesPerChar),
00055 maxBytesPerChar(maxBytesPerChar)
00056 { }
00057
00058 std::string name;
00059 ID id;
00060 float averageBytesPerChar;
00061 float maxBytesPerChar;
00062
00066 std::string Name() { return name; }
00067
00071 static Encoding* get(char const* name);
00072
00076 static Encoding* get(ID id);
00077
00088 size_t Encode(Encoding* fromCode, char const* in, size_t inlen,
00089 char*& out, size_t outlen = 0);
00090
00094 static void Register(Encoding* encoding);
00095 static void Register(char const* alias, char const* canonical);
00096 };
00097
00098 }
00099 }
00100
00101 #endif // Tanl_text_Encoding_H