Fix T47856: Cycles problem when running from multi-byte path
This is a mix of regression and old unsupported configuration. Regression was caused by some checks added on Blender side which was checking whether python function returned error or not. This made it impossible to enable Cycles when running from a file path which can't be encoded with MBCS codepage. Non-regression issue was that it wasn't possible to use pre-compiled CUDA kernels when running from a path with non-ascii multi-byte characters. This commit fixes regression and CUDA parts, but OSL still can't be used from a non-ascii location because it uses non-widechar API to work with file paths by the looks of it. Not sure we can solve this just from our side by using some codepage trick (UTF-16?) since even oslc fails to compile shader when there are non-ascii characters in the path.
This commit is contained in:
@@ -165,14 +165,14 @@ string string_from_bool(bool var)
|
||||
|
||||
wstring string_to_wstring(const string& str)
|
||||
{
|
||||
const int length_wc = MultiByteToWideChar(CP_ACP,
|
||||
const int length_wc = MultiByteToWideChar(CP_UTF8,
|
||||
0,
|
||||
str.c_str(),
|
||||
str.length(),
|
||||
NULL,
|
||||
0);
|
||||
wstring str_wc(length_wc, 0);
|
||||
MultiByteToWideChar(CP_ACP,
|
||||
MultiByteToWideChar(CP_UTF8,
|
||||
0,
|
||||
str.c_str(),
|
||||
str.length(),
|
||||
@@ -183,7 +183,7 @@ wstring string_to_wstring(const string& str)
|
||||
|
||||
string string_from_wstring(const wstring& str)
|
||||
{
|
||||
int length_mb = WideCharToMultiByte(CP_ACP,
|
||||
int length_mb = WideCharToMultiByte(CP_UTF8,
|
||||
0,
|
||||
str.c_str(),
|
||||
str.size(),
|
||||
@@ -191,7 +191,7 @@ string string_from_wstring(const wstring& str)
|
||||
0,
|
||||
NULL, NULL);
|
||||
string str_mb(length_mb, 0);
|
||||
WideCharToMultiByte(CP_ACP,
|
||||
WideCharToMultiByte(CP_UTF8,
|
||||
0,
|
||||
str.c_str(),
|
||||
str.size(),
|
||||
@@ -201,6 +201,42 @@ string string_from_wstring(const wstring& str)
|
||||
return str_mb;
|
||||
}
|
||||
|
||||
string string_to_ansi(const string& str)
|
||||
{
|
||||
const int length_wc = MultiByteToWideChar(CP_UTF8,
|
||||
0,
|
||||
str.c_str(),
|
||||
str.length(),
|
||||
NULL,
|
||||
0);
|
||||
wstring str_wc(length_wc, 0);
|
||||
MultiByteToWideChar(CP_UTF8,
|
||||
0,
|
||||
str.c_str(),
|
||||
str.length(),
|
||||
&str_wc[0],
|
||||
length_wc);
|
||||
|
||||
int length_mb = WideCharToMultiByte(CP_ACP,
|
||||
0,
|
||||
str_wc.c_str(),
|
||||
str_wc.size(),
|
||||
NULL,
|
||||
0,
|
||||
NULL, NULL);
|
||||
|
||||
string str_mb(length_mb, 0);
|
||||
WideCharToMultiByte(CP_ACP,
|
||||
0,
|
||||
str_wc.c_str(),
|
||||
str_wc.size(),
|
||||
&str_mb[0],
|
||||
length_mb,
|
||||
NULL, NULL);
|
||||
|
||||
return str_mb;
|
||||
}
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
Reference in New Issue
Block a user