occ-ai / obs-backgroundremoval

An OBS plugin for removing background in portrait images (video), making it easy to replace the background when recording or streaming.
GNU General Public License v2.0
2.7k stars 185 forks source link

Improve the handling of path string #528

Closed umireon closed 6 months ago

umireon commented 6 months ago

Closes #525

Given std::string s, s.c_str() will be released when s is released. If you want to use s.c_str() later, you have to hold s until you use s.c_str().

On Windows, char paths are stored as multi-byte characters which Windows defines and it is hard to manipulate them with C++ standard libraries (codecvt was deprecated in C++17) so I propose to convert multi-byte characters with Windows-specific API that is guaranteed to work with multi-byte characters on Windows.

umireon commented 6 months ago

I will check on Windows but it uses std::wstring on Windows.

umireon commented 6 months ago

I have checked it on Windows having multi-byte characters on the path and noticed that the current path handling wouldn't work under some conditions so I have added a code to handle multi-byte characters properly.

Please review again, @royshil