How to make XXXReader to support chinese file path under windows 7?

Hello,this code:

OBJReader reader=OBJReader::New();
//reader->SetFileName("/home/user/中文/model.obj"); //for linux
auto data = reader->GetOutput();

(vtk 9.1 is being used)

works properly under Windows 10(set UTF8 support in region setttings) and linux,but doesn’t work under windows 7.

How to make it work under windows 7(maybe all pre windows 10)?

Please try this

And see if it helps

Users cannot expect your application to support Windows 7 anymore. Even Microsoft dropped support for Windows 7 several years ago. Upgrading is not a personal preference because anybody using an operating system without security updates puts all computers in his entire organization at risk.

This should work out of the box on Windows 7. Does the path exist?

You have to encode text in utf8 format. Try

Are those paths hardcoded? If yes, then make sure your editor is saving the text characters properly (UTF-8). Also, it may look correct on screen and in the file, but can be misinterpreted by the compiler. So you need to tell the compiler how to read correctly whatever is enclosed by the quotation marks. Maybe prepending those hardcoded paths with an L in your source code (e.g. L"c://user/用户/中文/model.obj") will do.

1 Like

No,path string comes from a file selector of windows,it is a variable,not a hard coded string.

VTK works with utf8 on all versions of Windows. You can’t rely on regional settings for Windows before version 10.

Is the path obtained by the command line args in main()? You need to use GetCommandLineW (or wmain()) and covert the UTF-16 text to UTF-8.

Otherwise whatever Windows API function is supplying the text needs to be the W version (not the A version) and then do the conversion in your own code.