-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String encoding in source code #91
Comments
You are right about the confusion with the coding standard from Win32Clipboard.cpp (and static const UINT gFormatDescriptorBinary = RegisterClipboardFormatA("Binary");
static const UINT gFormatDescriptorDropEffect = RegisterClipboardFormatA("Preferred DropEffect"); I don't want to sound rude but I do not understand your point about supporting the ShellAnything is designed to be compiled without UNICODE (or _UNICODE). The main code is written to implicitly use the Wide variety of Win32 functions and not rely on macros based on Since data in ShellAnything is stored as UTF-8 strings , using Even if the Shell Extension is compiled without the UNICODE preprocessor, it is still registering itself as a wide-characters compatible application to the system. It is also using the wide variety of Win32 functions (functions names ending with W). If you need to define a string with Chinese characters, just use the wide function and use the |
ShellAnything works very well in non-English environment, and there is no compatibility problem. But I still recommend using a function like |
* Removed as much as possible the usage of WIN32 macros. Replaced by the actual ansi or wide variety. * Updated Win32Clipboard code. Replaced unicode-ready functions by utf-8-ready version. * Renamed InputBox::GetModuleHandle() function since it was conflicting with existing macros. The method is now renamed to GetInputBoxModuleHandle(). * Created new unit tests for supporting new Win32Clipboard utf-8 functions. For #91
* feature-issue91: Fixed ambiguities for using ansi or unicode versions of win32 functions. * Removed as much as possible the usage of WIN32 macros. Replaced by the actual ansi or wide variety. * Updated Win32Clipboard code. Replaced unicode-ready functions by utf-8-ready version. * Renamed InputBox::GetModuleHandle() function since it was conflicting with existing macros. The method is now renamed to GetInputBoxModuleHandle(). * Created new unit tests for supporting new Win32Clipboard utf-8 functions. For #91 Silenced the following warnings: // D:\Projects\ShellAnything\src\shellext.cpp(632) : warning C4311 : 'reinterpret_cast' : pointer truncation from 'LPCSTR' to 'int' // D:\Projects\ShellAnything\src\shellext.cpp(632) : warning C4302 : 'reinterpret_cast' : truncation from 'LPCSTR' to 'int' Created unicode version for `SetDragDropFilesUnicode()` and `GetAsDragDropFilesUnicode()`.
There are too many potential coding errors in source code
for example:
https://github.com/end2endzone/ShellAnything/blob/master/src/Win32Clipboard.cpp#L42
it only work right when not define
UNICODE
. AndRegisterClipboardFormatA
will convert"Binary"
toL"Binary"
, then callRegisterClipboardFormatW
.To improve compatibility, should write like
RegisterClipboardFormatA("Binary")
, orRegisterClipboardFormatW(L"Binary")
,or more appropriate:
RegisterClipboardFormat(TEXT"Binary"))
I tried to modify a part of the code, but I found that this caused coding confusion in the code.
So I recommend using
TCHAR
instead ofchar
,_stprintf_s
instead ofsprintf_s
,TEXT("bala")
instead of"bala"
or more cpp style
typedef basic_string<TCHAR, char_traits<TCHAR>, allocator<TCHAR> > tstring;
instead of
std::string
(ref: https://stackoverflow.com/questions/36197514/what-is-the-macro-for-stdstring-stdwstring-in-vc)
And define
UNICODE
and_UNICODE
The text was updated successfully, but these errors were encountered: