Initial community commit
This commit is contained in:
parent
537bcbc862
commit
fc06254474
16440 changed files with 4239995 additions and 2 deletions
43
Src/Plugins/Input/in_wmvdrm/AutoChar.h
Normal file
43
Src/Plugins/Input/in_wmvdrm/AutoChar.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
#ifndef NULLSOFT_AUTOCHARH
|
||||
#define NULLSOFT_AUTOCHARH
|
||||
|
||||
class AutoChar
|
||||
{
|
||||
public:
|
||||
AutoChar(const wchar_t *convert) : allocated(false), narrow(0)
|
||||
{
|
||||
// review maybe CP_UTF8?
|
||||
|
||||
int size = WideCharToMultiByte(CP_ACP, 0, convert, -1, 0, 0, NULL, NULL);
|
||||
if (!size)
|
||||
return;
|
||||
|
||||
narrow = new char[size];
|
||||
allocated=true;
|
||||
|
||||
if (!WideCharToMultiByte(CP_ACP, 0, convert, -1, narrow, size, NULL, NULL))
|
||||
{
|
||||
delete [] narrow;
|
||||
narrow=0;
|
||||
allocated=false;
|
||||
}
|
||||
}
|
||||
~AutoChar()
|
||||
{
|
||||
if (allocated)
|
||||
{
|
||||
delete [] narrow;
|
||||
narrow=0;
|
||||
allocated=false;
|
||||
}
|
||||
}
|
||||
operator char *()
|
||||
{
|
||||
return narrow;
|
||||
}
|
||||
private:
|
||||
bool allocated;
|
||||
char *narrow;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue