diff --git a/inc/hgl/CodePage.h b/inc/hgl/CodePage.h index 806b3c2..e8fb81f 100644 --- a/inc/hgl/CodePage.h +++ b/inc/hgl/CodePage.h @@ -13,41 +13,41 @@ namespace hgl constexpr struct CodePageAndCharSet CodePage2CharSet[]= { - {ccpNone, "us-ascii" }, + {CharCodePage::NONE, "us-ascii" }, - {ccpGBK, "gbk" }, - {ccpBig5, "big5" }, - {ccpGB2312, "gb2312" }, - {ccpGB18030, "gb18030" }, + {CharCodePage::GBK, "gbk" }, + {CharCodePage::Big5, "big5" }, + {CharCodePage::GB2312, "gb2312" }, + {CharCodePage::GB18030, "gb18030" }, - {ccpShiftJIS, "shift-jis" }, - {ccpJISX, "iso-2022-jp" }, + {CharCodePage::ShiftJIS, "shift-jis" }, + {CharCodePage::JISX, "iso-2022-jp" }, - {ccpKorean, "ks_c_5601-1987"}, + {CharCodePage::Korean, "ks_c_5601-1987"}, - {ccpMacJanpan, "x-mac-japanese" }, - {ccpMacTraditionalChinese, "x-mac-chinesetrad" }, - {ccpMacSimplifiedChinese, "x-mac-chinesesimp" }, + {CharCodePage::MacJanpan, "x-mac-japanese" }, + {CharCodePage::MacTraditionalChinese, "x-mac-chinesetrad" }, + {CharCodePage::MacSimplifiedChinese, "x-mac-chinesesimp" }, - {ccp8859_1, "iso-8859-1"}, - {ccp8859_2, "iso-8859-2"}, - {ccp8859_3, "iso-8859-3"}, - {ccp8859_4, "iso-8859-4"}, - {ccp8859_5, "iso-8859-5"}, - {ccp8859_6, "iso-8859-6"}, - {ccp8859_7, "iso-8859-7"}, - {ccp8859_8, "iso-8859-8"}, - {ccp8859_9, "iso-8859-9"}, - {ccp8859_13, "iso-8859-13"}, - {ccp8859_15, "iso-8859-15"}, + {CharCodePage::ISO_8859_1, "iso-8859-1"}, + {CharCodePage::ISO_8859_2, "iso-8859-2"}, + {CharCodePage::ISO_8859_3, "iso-8859-3"}, + {CharCodePage::ISO_8859_4, "iso-8859-4"}, + {CharCodePage::ISO_8859_5, "iso-8859-5"}, + {CharCodePage::ISO_8859_6, "iso-8859-6"}, + {CharCodePage::ISO_8859_7, "iso-8859-7"}, + {CharCodePage::ISO_8859_8, "iso-8859-8"}, + {CharCodePage::ISO_8859_9, "iso-8859-9"}, + {CharCodePage::ISO_8859_13, "iso-8859-13"}, + {CharCodePage::ISO_8859_15, "iso-8859-15"}, - {ccpUTF7, "utf-7" }, - {ccpUTF8, "utf-8" }, + {CharCodePage::UTF7, "utf-7" }, + {CharCodePage::UTF8, "utf-8" }, - {ccpUTF16LE, "utf-16le" }, - {ccpUTF16BE, "utf-16be" }, - {ccpUTF32LE, "utf-32le" }, - {ccpUTF32BE, "utf-32be" }, + {CharCodePage::UTF16LE, "utf-16le" }, + {CharCodePage::UTF16BE, "utf-16be" }, + {CharCodePage::UTF32LE, "utf-32le" }, + {CharCodePage::UTF32BE, "utf-32be" }, };//const struct constexpr int CharSetCount=sizeof(CodePage2CharSet)/sizeof(CodePageAndCharSet); @@ -63,48 +63,51 @@ namespace hgl constexpr struct CodePageAndCharSet CodeSet2CharPage[]= { - {ccpNone, "us-ascii" }, + {CharCodePage::NONE, "us-ascii" }, - {ccpGBK, "gbk" }, + {CharCodePage::GBK, "gbk" }, - {ccpBig5, "big5" }, - {ccpBig5, "bigfive" }, + {CharCodePage::Big5, "big5" }, + {CharCodePage::Big5, "bigfive" }, - {ccpGB2312, "gb2312" }, - {ccpGB18030, "gb18030" }, + {CharCodePage::GB2312, "gb2312" }, + {CharCodePage::GB18030, "gb18030" }, - {ccpShiftJIS, "shift_jis" }, - {ccpJISX, "iso-2022-jp" }, + {CharCodePage::ShiftJIS, "shift_jis" }, + {CharCodePage::JISX, "iso-2022-jp" }, - {ccpKorean, "ks_c_5601-1987"}, + {CharCodePage::Korean, "ks_c_5601-1987"}, - {ccpMacJanpan, "x-mac-japanese" }, - {ccpMacTraditionalChinese, "x-mac-chinesetrad" }, - {ccpMacSimplifiedChinese, "x-mac-chinesesimp" }, + {CharCodePage::MacJanpan, "x-mac-japanese" }, + {CharCodePage::MacTraditionalChinese, "x-mac-chinesetrad" }, + {CharCodePage::MacSimplifiedChinese, "x-mac-chinesesimp" }, - {ccp8859_1, "iso-8859-1"}, - {ccp8859_2, "iso-8859-2"}, - {ccp8859_3, "iso-8859-3"}, - {ccp8859_4, "iso-8859-4"}, - {ccp8859_5, "iso-8859-5"}, - {ccp8859_6, "iso-8859-6"}, - {ccp8859_7, "iso-8859-7"}, - {ccp8859_8, "iso-8859-8"}, - {ccp8859_9, "iso-8859-9"}, - {ccp8859_13, "iso-8859-13"}, - {ccp8859_15, "iso-8859-15"}, + {CharCodePage::ISO_8859_1, "iso-8859-1"}, + {CharCodePage::ISO_8859_2, "iso-8859-2"}, + {CharCodePage::ISO_8859_3, "iso-8859-3"}, + {CharCodePage::ISO_8859_4, "iso-8859-4"}, + {CharCodePage::ISO_8859_5, "iso-8859-5"}, + {CharCodePage::ISO_8859_6, "iso-8859-6"}, + {CharCodePage::ISO_8859_7, "iso-8859-7"}, + {CharCodePage::ISO_8859_8, "iso-8859-8"}, + {CharCodePage::ISO_8859_9, "iso-8859-9"}, + {CharCodePage::ISO_8859_13, "iso-8859-13"}, + {CharCodePage::ISO_8859_15, "iso-8859-15"}, - {ccpUTF7, "utf7" }, - {ccpUTF8, "utf8" }, - {ccpUTF16LE, "utf16le" }, - {ccpUTF16BE, "utf16be" }, - {ccpUTF32LE, "utf32le" }, - {ccpUTF32BE, "utf32be" }, + {CharCodePage::UTF7, "utf-7" }, + {CharCodePage::UTF8, "utf-8" }, + {CharCodePage::UTF16LE, "utf-16le" }, + {CharCodePage::UTF16BE, "utf-16be" }, + {CharCodePage::UTF32LE, "utf-32le" }, + {CharCodePage::UTF32BE, "utf-32be" }, - {ccpUTF16LE, "ucs2le" }, - {ccpUTF16BE, "ucs2be" }, - {ccpUTF32LE, "ucs4le" }, - {ccpUTF32BE, "ucs4be" } + {CharCodePage::UTF16LE, "utf-16" }, + {CharCodePage::UTF16BE, "unicodeFFFE"}, + + {CharCodePage::UTF16LE, "ucs-2le" }, + {CharCodePage::UTF16BE, "ucs-2be" }, + {CharCodePage::UTF32LE, "ucs-4le" }, + {CharCodePage::UTF32BE, "ucs-4be" } };//const struct CharSet Characters constexpr int CharPageCount=sizeof(CodeSet2CharPage)/sizeof(CodePageAndCharSet); @@ -115,7 +118,7 @@ namespace hgl if(!charset_cmp(CodePage2CharSet[i].charset,char_set)) return CodePage2CharSet[i].codepage; - return ccpNone; + return CharCodePage::NONE; } struct CharSet @@ -127,14 +130,14 @@ namespace hgl CharSet() { - codepage=ccpNone; - hgl::strcpy(charset,CharSetNameLength,"us-ascii"); + codepage=CharCodePage::NONE; + hgl::strcpy(charset,CHAR_SET_NAME_MAX_LENGTH,"us-ascii"); } CharSet(CharCodePage ccp,const char *cs) { codepage=ccp; - hgl::strcpy(charset,CharSetNameLength,cs); + hgl::strcpy(charset,CHAR_SET_NAME_MAX_LENGTH,cs); } CharSet(CharCodePage); @@ -143,23 +146,23 @@ namespace hgl CharSet(const CodePageAndCharSet &cs) { codepage=cs.codepage; - strcpy(charset,CharSetNameLength,cs.charset); + strcpy(charset,CHAR_SET_NAME_MAX_LENGTH,cs.charset); } - int _Comp(const CharSet &data)const{return codepage-data.codepage;} \ + int _Comp(const CharSet &data)const{return (size_t)codepage-(size_t)data.codepage;} \ CompOperator(const CharSet &,_Comp) };//struct CharacterSet inline CharSet::CharSet(CharCodePage ccp) { codepage=ccp; - hgl::strcpy(charset,CharSetNameLength,FindCharSet(ccp)); + hgl::strcpy(charset,CHAR_SET_NAME_MAX_LENGTH,FindCharSet(ccp)); } inline CharSet::CharSet(const u8char *cs) { codepage=FindCodePage(cs); - hgl::strcpy(charset,CharSetNameLength,FindCharSet(codepage)); + hgl::strcpy(charset,CHAR_SET_NAME_MAX_LENGTH,FindCharSet(codepage)); } extern CharSet DefaultCharSet(); diff --git a/inc/hgl/Endian.h b/inc/hgl/Endian.h index b04466c..f07d48b 100644 --- a/inc/hgl/Endian.h +++ b/inc/hgl/Endian.h @@ -12,51 +12,51 @@ namespace hgl * 全部Windows所支持代码页请参见 http://msdn.microsoft.com/en-us/library/dd317756 * https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers */ - enum CharCodePage ///代码页枚举 + enum class CharCodePage ///代码页枚举 { - ccpNone=0, ///<起始定义,无意义 + NONE=0, ///<起始定义,无意义 //中文 - ccpGBK =936, ///<中国GBK标准中文 - ccpBig5 =950, ///<中国台湾Big5标准繁体中文 - ccpGB2312 =20936, ///<中国GB2312标准简体中文 - ccpGB18030 =54936, ///<中国GB18030-2000标准中文 + GBK =936, ///<中国GBK标准中文 + Big5 =950, ///<中国台湾Big5标准繁体中文 + GB2312 =20936, ///<中国GB2312标准简体中文 + GB18030 =54936, ///<中国GB18030-2000标准中文 //日文 - ccpShiftJIS =932, ///<日文ShiftJIS - ccpJISX =50222, ///<日文JIS X/ISO 2022 + ShiftJIS =932, ///<日文ShiftJIS + JISX =50222, ///<日文JIS X/ISO 2022 //韩文 - ccpKorean =949, ///<韩文 + Korean =949, ///<韩文 //苹果编码 - ccpMacJanpan =10001, ///<日文 - ccpMacTraditionalChinese =10002, ///<繁体中文 - ccpMacSimplifiedChinese =10008, ///<简体中文 + MacJanpan =10001, ///<日文 + MacTraditionalChinese =10002, ///<繁体中文 + MacSimplifiedChinese =10008, ///<简体中文 //ISO - ccp8859_1 =28591, /// const CharSetName &GetCurCharSet(); ///<取得当前程序编码字符集 @@ -113,11 +113,11 @@ namespace hgl */ constexpr BOMFileHeader BOMData[size_t(ByteOrderMask::RANGE_SIZE)]= { - {3,{0xEF,0xBB,0xBF} ,ByteOrderMask::UTF8, &utf8_charset ,ccpUTF8 }, - {2,{0xFF,0xFE} ,ByteOrderMask::UTF16LE,&utf16le_charset ,ccpUTF16LE }, - {2,{0xFE,0xFF} ,ByteOrderMask::UTF16BE,&utf16be_charset ,ccpUTF16BE }, - {4,{0xFF,0xFE,0x00,0x00},ByteOrderMask::UTF32LE,&utf32le_charset ,ccpUTF32LE }, - {4,{0x00,0x00,0xFE,0xFF},ByteOrderMask::UTF32BE,&utf32be_charset ,ccpUTF32BE } + {3,{0xEF,0xBB,0xBF} ,ByteOrderMask::UTF8, &utf8_charset ,CharCodePage::UTF8 }, + {2,{0xFF,0xFE} ,ByteOrderMask::UTF16LE,&utf16le_charset ,CharCodePage::UTF16LE }, + {2,{0xFE,0xFF} ,ByteOrderMask::UTF16BE,&utf16be_charset ,CharCodePage::UTF16BE }, + {4,{0xFF,0xFE,0x00,0x00},ByteOrderMask::UTF32LE,&utf32le_charset ,CharCodePage::UTF32LE }, + {4,{0x00,0x00,0xFE,0xFF},ByteOrderMask::UTF32BE,&utf32be_charset ,CharCodePage::UTF32BE } }; inline ByteOrderMask CheckBOM(const void *data) diff --git a/inc/hgl/type/Collection.h b/inc/hgl/type/Collection.h index a5609bf..6686ed3 100644 --- a/inc/hgl/type/Collection.h +++ b/inc/hgl/type/Collection.h @@ -101,7 +101,7 @@ namespace hgl public: - Collection(const size_t ub=1,MemoryBlock *mb=new MemoryBlock); + Collection(const uint32 ub=1,MemoryBlock *mb=new MemoryBlock); virtual ~Collection(); virtual bool Alloc(const uint64 count); ///<预分配空间 diff --git a/src/Text/CodePage.cpp b/src/Text/CodePage.cpp index 5327753..a2b1003 100644 --- a/src/Text/CodePage.cpp +++ b/src/Text/CodePage.cpp @@ -4,9 +4,9 @@ namespace hgl { CharSet DefaultCharSet(); - CharSet UTF8CharSet (ccpUTF8, utf8_charset ); - CharSet UTF16LECharSet (ccpUTF16LE,utf16le_charset ); - CharSet UTF16BECharSet (ccpUTF16BE,utf16be_charset ); + CharSet UTF8CharSet (CharCodePage::UTF8, utf8_charset ); + CharSet UTF16LECharSet (CharCodePage::UTF16LE,utf16le_charset ); + CharSet UTF16BECharSet (CharCodePage::UTF16BE,utf16be_charset ); int u16_to_u8(u8char *dst,int dst_size,const u16char *src,const int src_size) { diff --git a/src/Type/Collection.cpp b/src/Type/Collection.cpp index 271148f..fcbb89e 100644 --- a/src/Type/Collection.cpp +++ b/src/Type/Collection.cpp @@ -2,7 +2,7 @@ namespace hgl { - Collection::Collection(const size_t ub,MemoryBlock *mb) + Collection::Collection(const uint32 ub,MemoryBlock *mb) { unit_bytes=ub; memory_block=mb;