Re: version.h and unicode
Take a look at Unicode topics.
Re: version.h and unicode
Thanks ovidiucucu, I'll check it out.
:-)
Re: version.h and unicode
Unicode is bit boaring for the programming purpose. U need to convert all string variables into unicode format e.g char buf[80] -> TCHAR buf[80]. U need to use unicode specific functions that u will find on net. e.g fopen -> _tfopen etc.
u will need to load strings from string table to serve the purpose of using unicode.
what is ur purpose of using unicode ?
Re: version.h and unicode
I'm writing a subcaptioning system for DCI compliant digital cinema projectors (the ones that play the 3D movies). I used version.h to interrogate the version string information in my source code, but I can't get it to compile because of unicode.
I need unicode to support languages worldwide.
Version.h uses std::string, and I don't know how to use this with unicode.
Thanks
Steve Q.
Re: version.h and unicode
std::string has its Unicode version std::wstring.
Re: version.h and unicode
thanks ovidiucucu, I found this about 30secs before your post came in!
I have almost fixed it now, but have 2 errors to go.
This cast is causing me issues:
Code:
const_cast<LPTSTR>(strsTemp.str().c_str()),
compiler error:
Code:
error C2440: 'const_cast' : cannot convert from 'const char *' to 'LPTSTR' version.h 120
Thanks again all,
Steve Q.
Re: version.h and unicode
Quote:
Originally Posted by
ManishaSantosh
[...] U need to convert all string variables into unicode format e.g char buf[80] -> TCHAR buf[80]. U need to use unicode specific functions that u will find on net. e.g fopen -> _tfopen etc.
Neither TCHAR buf[80] is a "string vartiable in unicode format", nor _tfopen is "unicode specific function".
Both ar just macros, defined in TCHAR.H.
Re: version.h and unicode
Quote:
Originally Posted by
steveq
This cast is causing me issues:
Code:
const_cast<LPTSTR>(strsTemp.str().c_str()),
compiler error:
Code:
error C2440: 'const_cast' : cannot convert from 'const char *' to 'LPTSTR' version.h 120
Never cast ANSI strings to Unicode and vice-versa.
If necessary use conversion functions or macros.
See this thread: http://www.codeguru.com/forum/showth...light=wcstombs
Re: version.h and unicode
Ok so do you mean I have to convert:
Code:
strsTemp.str().c_str()
Before it is passed to the function...
To be honest I'm still not sure how to fix this. I get the same error with this:
Code:
return static_cast<LPTSTR>(pvValue);
Compiler error:
Code:
error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(const _Elem *)' : cannot convert parameter 1 from 'LPTSTR' to 'const char *' version.h 123
Thanks again. :)
Re: version.h and unicode
Sorry I should have posted the offending code, here it is:
Code:
if(::VerQueryValue(static_cast<LPVOID>(m_pucResourceData),
const_cast<LPTSTR>(strsTemp.str().c_str()),
static_cast<LPVOID *>(&pvValue),
&uiSize) != FALSE)
return static_cast<LPTSTR>(pvValue);
Re: version.h and unicode
what is strsTemp? Is it a stringstream beacause std::string does not have a member functions called str().
Re: version.h and unicode
Yeah it is:
Code:
if(m_pucResourceData)
{
UINT uiSize = 0;
std::stringstream strsTemp;
LPVOID pvValue = 0;
// Build query string
strsTemp << "\\StringFileInfo\\" << std::setw(4) << std::setfill('0') << std::hex
<< m_pLanguageInformation->m_wLanguage << std::setw(4) << std::hex
<< m_pLanguageInformation->m_wCodePage << "\\" << refcstrKey;
if(::VerQueryValue(static_cast<LPVOID>(m_pucResourceData),
const_cast<LPTSTR>(strsTemp.str().c_str()),
static_cast<LPVOID *>(&pvValue),
&uiSize) != FALSE)
return static_cast<LPTSTR>(pvValue);
}
Re: version.h and unicode
use std::wstringstream and u're OK.
http://msdn.microsoft.com/en-us/libr...=vs.71%29.aspx
Also use the wide version of string literals
Code:
L"\\StringFileInfo\\"
or
Code:
_T("\\StringFileInfo\\")
Re: version.h and unicode
Thanks SkyNetTo.
I tried that, but got more errors:
Code:
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::_Fillobj<_Elem>' (or there is no acceptable conversion) version.h 115
error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(const _Elem *)' : cannot convert parameter 1 from 'LPTSTR' to 'const char *' version.h 123
??
Thanks heaps for your help :)