00001 #include "dxlibp.h"
00002
00003 #define DXPCPTABLE_MAX 20
00004
00005 #define DXPCPTABLE_FILENAME "flash0:/vsh/etc/cptbl.dat"
00006
00007 #define DXPCP_TOUCS2 0
00008 #define DXPCP_FROMUCS2 1
00009
00010 typedef u16 dxpUcs2;
00011 typedef u8 dxpChar;
00012
00013 typedef struct DXPCPTABLE_HEADER__
00014 {
00015 u16 startcode;
00016 u16 endcode;
00017 u16 offset;
00018 }DXPCPTABLE_HEADER;
00019
00020
00021 typedef struct DXPCPTABLE__
00022 {
00023 u8 used;
00024 void* ptr;
00025 void* end;
00026 }DXPCPTABLE;
00027
00028 typedef struct DXPCPDATA__
00029 {
00030 unsigned init:1;
00031 dxpUcs2 errcode_ucs2;
00032 DXPCPTABLE table[DXPCPTABLE_MAX][2];
00033 }DXPCPDATA;
00034
00035 extern DXPCPDATA dxpCpData;
00036
00037 void dxpCpInit();
00038 int dxpCpLoadTable(const char *filename,u8 cp,u8 direction);
00039
00040 int MultiByteCharCheck( const char *Buf, int CharSet );;
00041
00042 int dxpCpSJIS_MultiByteCharCheck(dxpChar code);
00043 int dxpCpSJIS_Strlen(const dxpChar *str);
00044 int dxpCpSJIS_toUcs2(dxpUcs2 *dst,u32 count,const dxpChar *src);
00045 int dxpCpSJIS_fromUcs2(dxpChar *dst,u32 count,const dxpUcs2 *src);
00046
00047 int dxpCpUTF8_toUcs2(dxpUcs2 *dst,u32 count,const dxpChar *src);
00048 int dxpCpUTF8_fromUcs2(dxpChar *dst,u32 count,const dxpUcs2 *src);
00049 int dxpCpUTF8_Strlen(const dxpChar *str);
00050 static inline int dxpCpUTF8_Charlen(const dxpChar *code)
00051 {
00052 if(!code)return -1;
00053 if(*code <= 0x7f)return 1;
00054 if(*code <= 0xc1)return -1;
00055 if(*code <= 0xdf)return 2;
00056 if(*code <= 0xef)return 3;
00057 if(*code <= 0xf7)return 4;
00058 if(*code <= 0xfb)return 5;
00059 if(*code <= 0xfd)return 6;
00060 return -1;
00061 }
00062
00063 int dxpCpCode_Strlen(const dxpChar *str,u8 cp);
00064 int dxpCpCode_toUcs2(dxpUcs2 *dst,u32 count,const dxpChar *src,u8 cp);
00065 int dxpCpCode_fromUcs2(dxpChar *dst,u32 count,const dxpUcs2 *src,u8 cp);
00066 int dxpCpUCS2_Strlen(const dxpUcs2 *str);