| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #ifndef RVC_MOD_UPLOAD_XUNZIP_ZLIB_H_
- #define RVC_MOD_UPLOAD_XUNZIP_ZLIB_H_
- #include "SpBase.h"
- #ifdef RVC_OS_WIN
- #define ZLIB_WINAPI //win32 必须使用的宏
- #endif
- #include "zip.h"
- #include "unzip.h"
- #include <iostream>
- #include <stdio.h>
- #include <string>
- #include <locale>
- #include <codecvt>
- using namespace std;
- //GBK转UTF码类
- class chs_codecvt : public std::codecvt_byname<wchar_t, char, std::mbstate_t> {
- public:
- //因不同平台,名称不同,故这里做转换,统一取出不同平台下面的GBK码
- #ifdef RVC_OS_WIN
- chs_codecvt() : codecvt_byname("chs") { }//zh_CN.GBK or .936
- #else
- chs_codecvt() : codecvt_byname("zh_CN.GBK") { }//.936
- #endif // RVC_OS_WIN
- };
- //src必须是UTF8否则抛异常
- static wstring utf8_to_wstr(const string& src)
- {
- wstring_convert<codecvt_utf8<wchar_t>> converter;
- return converter.from_bytes(src);
- }
- static string wstr_to_utf8(const wstring& src)
- {
- wstring_convert<codecvt_utf8<wchar_t>> convert;
- return convert.to_bytes(src);
- }
- static string utf8_to_gbk(const string& str)
- {
- wstring wStr = utf8_to_wstr(str);//utf8转wstring
- wstring_convert<chs_codecvt> converter;
- return converter.to_bytes(wStr);//wstring转GBK
- }
- static string gbk_to_utf8(const string& str)
- {
- wstring_convert<chs_codecvt> converter;
- wstring wStr = converter.from_bytes(str);//GBK转wstring
- return wstr_to_utf8(wStr);//wstring 转utf8
- }
- int UnZipToDir(string zipFileName, string destDirPath);
- int unZipCurrentFile(zipFile zf, string destDirPath);
- bool is_str_utf8(const char* str);
- #ifdef RVC_OS_WIN
- #else
- unsigned char* utf8_string_create(const char* string);
- #endif // RVC_OS_WIN
- #endif //RVC_MOD_UPLOAD_XUNZIP_ZLIB_H_
|