From 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d Mon Sep 17 00:00:00 2001 From: Jef Date: Tue, 24 Sep 2024 14:54:57 +0200 Subject: Initial community commit --- Src/Plugins/Input/in_wmvdrm/AutoWide.h | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Src/Plugins/Input/in_wmvdrm/AutoWide.h (limited to 'Src/Plugins/Input/in_wmvdrm/AutoWide.h') diff --git a/Src/Plugins/Input/in_wmvdrm/AutoWide.h b/Src/Plugins/Input/in_wmvdrm/AutoWide.h new file mode 100644 index 00000000..9248dda6 --- /dev/null +++ b/Src/Plugins/Input/in_wmvdrm/AutoWide.h @@ -0,0 +1,41 @@ +#ifndef AUTOWIDEH +#define AUTOWIDEH + +class AutoWide +{ +public: + AutoWide(const char *convert) : allocated(false), wide(0) + { + // review maybe CP_UTF8? + int size = MultiByteToWideChar(CP_ACP, 0, convert, -1, 0,0); + if (!size) + return; + + wide = new unsigned short[size]; + allocated=true; + if (!MultiByteToWideChar(CP_ACP, 0, convert, -1, wide,size)) + { + delete wide; + wide=0; + allocated=false; + } + } + ~AutoWide() + { + if (allocated) + { + delete wide; + wide=0; + allocated=false; + } + } + operator unsigned short *() + { + return wide; + } +private: + bool allocated; + unsigned short *wide; +}; + +#endif \ No newline at end of file -- cgit