charset.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef TOOLKIT_CHARACHER_SET_H__
  2. #define TOOLKIT_CHARACHER_SET_H__
  3. #pragma once
  4. #include "config.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. typedef
  9. enum char_encoding_enu {
  10. unknown, ansi, unicode, unicode_with_big_endian, unicode_with_bom, unicode_without_bom
  11. } char_encoding;
  12. TOOLKIT_API int toolkit_utf82gbk(char* inbuf, size_t inlen, char* outbuf, size_t outlen);
  13. TOOLKIT_API int toolkit_gbk2utf8(char* inbuf, size_t inlen, char* outbuf, size_t outlen);
  14. /*0: not-utf8, 1: utf-8: -1: analyze failed*/
  15. TOOLKIT_API int toolkit_detect_utf8_file(const char* file_path);
  16. //test now
  17. TOOLKIT_API char_encoding detect_file_encoding(const char* file_path);
  18. TOOLKIT_API int toolkit_detect_utf8_str(const char* str);
  19. /** from upgradetask [Gifur@2025725]*/
  20. //1:utf8;0:no utf8
  21. TOOLKIT_API int toolkit_detect_utf8_str2(const char* str);
  22. TOOLKIT_API size_t toolkit_mbs2wcs(const char* src, wchar_t* dst, size_t dst_size);
  23. TOOLKIT_API size_t toolkit_wcs2mbs(const wchar_t* src, char* dst, size_t dst_size);
  24. //only valid in win and the user remember to free the return if not null
  25. //return NULL input param directory in UOS, please use toolkit_utf82gbk if you need
  26. //copy from httpclient.h
  27. TOOLKIT_API char* ConvertUtf8ToGBK(const char* strUtf8);
  28. //only valid in win and the user remember to free the return if not null
  29. //return NULL directory in UOS, please use toolkit_gbk2utf8 if you need
  30. //copy from httpclient.h
  31. TOOLKIT_API char* ConvertGBKToUtf8(const char* gbk, int* n);
  32. #ifdef __cplusplus
  33. } // extern "C" {
  34. #endif
  35. #endif //TOOLKIT_CHARACHER_SET_H__