charset.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. //only valid in win and the user remember to free the return if not null
  20. //return strUtf8 input param directory in UOS, please use toolkit_utf82gbk if you need
  21. //copy from httpclient.h
  22. TOOLKIT_API char* ConvertUtf8ToGBK(const char* strUtf8);
  23. //only valid in win and the user remember to free the return if not null
  24. //return NULL directory in UOS, please use toolkit_gbk2utf8 if you need
  25. //copy from httpclient.h
  26. TOOLKIT_API char* ConvertGBKToUtf8(const char* gbk, int* n);
  27. #ifdef __cplusplus
  28. } // extern "C" {
  29. #endif
  30. #endif //TOOLKIT_CHARACHER_SET_H__