How to open the Chinese path of gdal gdalopen

Source: Internet
Author: User

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 ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.