Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
StrU.h
Go to the documentation of this file.
1 //
5 //
6 #ifndef _INC_StrU_H
7 #define _INC_StrU_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "StrChar.h"
13 #include "StrConst.h"
14 #include "cUnitTestDecl.h"
15 
16 namespace Gray
17 {
18  struct GRAYCORE_LINK StrU // : public StrT // static
19  {
22 
23  static const StrLen_t k_UTF8_SIZE_MAX = 4;
24 
26  {
33  UTFLead_0 = 0xefU, // Might be the first part of a UTF8 sequence or a special M$ signal.
34  UTFLead_1 = 0xbbU,
35  UTFLead_2 = 0xbfU,
36  UTFLead_X = 0xbeU, // alternate.
37  };
38 
39  static bool GRAYCALL IsUTFLead(const void* pvU);
40 
41  static StrLen_t GRAYCALL UTF8Size(wchar_t wChar, int& riStartBits);
42  static StrLen_t GRAYCALL UTF8Size1(unsigned char chFirst, int& riStartBits);
43  static StrLen_t GRAYCALL UTF8Size(const char* pInp, StrLen_t iSizeInpBytes, int& riStartBits);
44  static StrLen_t GRAYCALL UTF8toUNICODE(wchar_t& wChar, const char* pInp, StrLen_t iSizeInpBytes);
45  static StrLen_t GRAYCALL UNICODEtoUTF8(char* pOut, StrLen_t iSizeOutMaxBytes, wchar_t wChar);
46 
47  static StrLen_t GRAYCALL UTF8toUNICODELen(const char* pInp, StrLen_t iSizeInpBytes = k_StrLen_UNK);
48  static StrLen_t GRAYCALL UNICODEtoUTF8Size(const wchar_t* pInp, StrLen_t iSizeInpChars = k_StrLen_UNK);
49 
50  static StrLen_t GRAYCALL UTF8toUNICODE(OUT wchar_t* pOut, StrLen_t iSizeOutMaxChars, const char* pInp, StrLen_t iSizeInpBytes = k_StrLen_UNK);
51  static StrLen_t GRAYCALL UNICODEtoUTF8(OUT char* pOut, StrLen_t iSizeOutMaxBytes, const wchar_t* pInp, StrLen_t iSizeInpChars = k_StrLen_UNK);
52 
54  };
55 }
56 
57 #endif // _INC_StrU_H
#define GRAYCORE_LINK
Definition: GrayCore.h:47
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define UNITTEST_FRIEND(n)
Define this in the class body to be unit tested. Allow the unit test to access private/protected stuf...
Definition: cUnitTestDecl.h:17
< The main namespace for all Core functions.
Definition: GrayCore.cpp:14
const StrLen_t k_StrLen_UNK
use the default/current length of the string argument.
Definition: StrConst.h:34
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32
Definition: StrU.h:19
UTFLead_TYPE
Definition: StrU.h:26