Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
651 B

  1. #ifndef _UTF8STR_H_
  2. #define _UTF8STR_H_
  3. class CUTF8String
  4. {
  5. public:
  6. CUTF8String(LPCWSTR pcwszUnicode) :
  7. m_pwszUnicode ((LPWSTR) pcwszUnicode),
  8. m_pszUTF8 (NULL),
  9. m_eAlloc (ALLOC_NONE),
  10. m_hr (S_OK) { };
  11. CUTF8String(LPCSTR pcszUTF8) :
  12. m_pszUTF8 ((LPSTR) pcszUTF8),
  13. m_pwszUnicode (NULL),
  14. m_eAlloc (ALLOC_NONE),
  15. m_hr (S_OK) { };
  16. ~CUTF8String();
  17. operator LPWSTR();
  18. operator LPSTR();
  19. HRESULT GetError() { return m_hr; };
  20. protected:
  21. VOID EncodeUTF8();
  22. VOID DecodeUTF8();
  23. HRESULT m_hr;
  24. LPWSTR m_pwszUnicode;
  25. LPSTR m_pszUTF8;
  26. enum
  27. {
  28. ALLOC_NONE,
  29. ALLOC_UNICODE,
  30. ALLOC_UTF8,
  31. } m_eAlloc;
  32. };
  33. #endif // ! _UTF8STR_H_