unicode.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef _RAR_UNICODE_
  2. #define _RAR_UNICODE_
  3. #if defined( _WIN_ALL)
  4. #define DBCS_SUPPORTED
  5. #endif
  6. bool WideToChar(const wchar *Src,char *Dest,size_t DestSize);
  7. bool CharToWide(const char *Src,wchar *Dest,size_t DestSize);
  8. byte* WideToRaw(const wchar *Src,byte *Dest,size_t SrcSize);
  9. wchar* RawToWide(const byte *Src,wchar *Dest,size_t DestSize);
  10. void WideToUtf(const wchar *Src,char *Dest,size_t DestSize);
  11. size_t WideToUtfSize(const wchar *Src);
  12. bool UtfToWide(const char *Src,wchar *Dest,size_t DestSize);
  13. bool IsTextUtf8(const byte *Src);
  14. bool IsTextUtf8(const byte *Src,size_t SrcSize);
  15. int wcsicomp(const wchar *s1,const wchar *s2);
  16. int wcsnicomp(const wchar *s1,const wchar *s2,size_t n);
  17. const wchar_t* wcscasestr(const wchar_t *str, const wchar_t *search);
  18. #ifndef SFX_MODULE
  19. wchar* wcslower(wchar *s);
  20. wchar* wcsupper(wchar *s);
  21. #endif
  22. int toupperw(int ch);
  23. int tolowerw(int ch);
  24. int atoiw(const wchar *s);
  25. int64 atoilw(const wchar *s);
  26. #ifdef DBCS_SUPPORTED
  27. class SupportDBCS
  28. {
  29. public:
  30. SupportDBCS();
  31. void Init();
  32. char* charnext(const char *s);
  33. bool IsLeadByte[256];
  34. bool DBCSMode;
  35. };
  36. extern SupportDBCS gdbcs;
  37. inline char* charnext(const char *s) {return (char *)(gdbcs.DBCSMode ? gdbcs.charnext(s):s+1);}
  38. inline bool IsDBCSMode() {return gdbcs.DBCSMode;}
  39. #else
  40. #define charnext(s) ((s)+1)
  41. #define IsDBCSMode() (false)
  42. #endif
  43. #endif