1 #ifndef _RAR_UNICODE_
2 #define _RAR_UNICODE_
3
4 #if defined( _WIN_ALL)
5 #define DBCS_SUPPORTED
6 #endif
7
8 bool WideToChar(const wchar *Src,char *Dest,size_t DestSize);
9 bool CharToWide(const char *Src,wchar *Dest,size_t DestSize);
10 byte* WideToRaw(const wchar *Src,byte *Dest,size_t SrcSize);
11 wchar* RawToWide(const byte *Src,wchar *Dest,size_t DestSize);
12 void WideToUtf(const wchar *Src,char *Dest,size_t DestSize);
13 size_t WideToUtfSize(const wchar *Src);
14 bool UtfToWide(const char *Src,wchar *Dest,size_t DestSize);
15 bool IsTextUtf8(const byte *Src);
16 bool IsTextUtf8(const byte *Src,size_t SrcSize);
17
18 int wcsicomp(const wchar *s1,const wchar *s2);
19 int wcsnicomp(const wchar *s1,const wchar *s2,size_t n);
20 const wchar_t* wcscasestr(const wchar_t *str, const wchar_t *search);
21 #ifndef SFX_MODULE
22 wchar* wcslower(wchar *s);
23 wchar* wcsupper(wchar *s);
24 #endif
25 int toupperw(int ch);
26 int tolowerw(int ch);
27 int atoiw(const wchar *s);
28 int64 atoilw(const wchar *s);
29
30 #ifdef DBCS_SUPPORTED
31 class SupportDBCS
32 {
33 public:
34 SupportDBCS();
35 void Init();
36
37 char* charnext(const char *s);
38 size_t strlend(const char *s);
39 char *strchrd(const char *s, int c);
40 char *strrchrd(const char *s, int c);
41 void copychrd(char *dest,const char *src);
42
43 bool IsLeadByte[256];
44 bool DBCSMode;
45 };
46
47 extern SupportDBCS gdbcs;
48
charnext(const char * s)49 inline char* charnext(const char *s) {return (char *)(gdbcs.DBCSMode ? gdbcs.charnext(s):s+1);}
strlend(const char * s)50 inline size_t strlend(const char *s) {return (uint)(gdbcs.DBCSMode ? gdbcs.strlend(s):strlen(s));}
strchrd(const char * s,int c)51 inline char* strchrd(const char *s, int c) {return (char *)(gdbcs.DBCSMode ? gdbcs.strchrd(s,c):strchr(s,c));}
strrchrd(const char * s,int c)52 inline char* strrchrd(const char *s, int c) {return (char *)(gdbcs.DBCSMode ? gdbcs.strrchrd(s,c):strrchr(s,c));}
copychrd(char * dest,const char * src)53 inline void copychrd(char *dest,const char *src) {if (gdbcs.DBCSMode) gdbcs.copychrd(dest,src); else *dest=*src;}
IsDBCSMode()54 inline bool IsDBCSMode() {return(gdbcs.DBCSMode);}
InitDBCS()55 inline void InitDBCS() {gdbcs.Init();}
56
57 #else
58 #define charnext(s) ((s)+1)
59 #define strlend strlen
60 #define strchrd strchr
61 #define strrchrd strrchr
62 #define IsDBCSMode() (true)
copychrd(char * dest,const char * src)63 inline void copychrd(char *dest,const char *src) {*dest=*src;}
64 #endif
65
66
67 #endif
68