I'm working on writing some libraries that will be used both internally and by customers and was wondering what the best method of supporting both Unicode and ASCII. It looks like Microsoft (in the MFC Libraries) writes both the Unicode and ASCII classes and does something similar to this in the header files using macros:
#ifdef _UNICODE
#define CString CStringW
#else
#define CString CStringA
#endif
While I'm not a huge fan of macros, it does the job. If I'm writing libraries using the STL, does it make sense to write headers that contain things like this:
#ifdef _UNICODE
#define GetLastErrorString GetLastErrorStringW
#else
#define GetLastErrorString GetLastErrorStringA
#endif
std::string GetLastErrorStringA();
std::wstring GetLastErrorStringW();
Or should I just release separate libraries, one for ASCII and one for Unicode?
Just wondering what people think is the best thing to do in this situation.
UPDATE: Addressing some comments and questions:
- These will be C++ class libraries.
- I believe I will need to use UTF-16 encoding as I would like to support Asian character sets.
- My reasons for implementing Unicode are twofold: 1) All new SDKs support Unicode and I'm not confident that future SDKs or third party libraries will be supporting separate ASCII versions in the future. 2) While we will not be completely internationalizing our application, it would be nice if we could handle user input (like names) and files loading from paths that contain Asian characters.