Today, I encountered a problem. After debugging for a long time, I used gdal to open the image. I first converted the qstring type path name into char * and tried many methods, no matter how the conversion is done, an error is prompted, and char * is directly used to point to the path name, or an error occurs. If the path name does not contain Chinese characters, no problem is found. So the problem is not here. The problem lies in the gdalopen function, which is strange. gdal in Linux does not have this problem. This problem occurs in vs2008 in windows. Find an article on the Internet at http://blog.csdn.net/liminlu0314/article/details/6610069.
The reason is as follows: the latest gdal1.9 is used. The gdal function cplgetconfigoption ("gdal_filename_is_utf8", "yes") is used to determine whether the code is utf8, in addition, the default value is utf8 encoding. Most of the encoding of strings containing Chinese paths should be GBK encoding. In this way, the system uses GBK Encoding As utf8 encoding for conversion, the result is that all Chinese characters are garbled, and the result is that the file cannot be found, so it cannot be opened.
Solution:
Without changing the gdal source code, add the following sentence after calling the gdalregisterall () and ograllregiser () functions. Cplsetconfigoption ("gdal_filename_is_utf8", "no ");