Opened 13 years ago
Closed 13 years ago
#4097 closed defect (invalid)
GDAL 1.8.0 cannot open an image file in Chinese.
Reported by: | davidhopper | Owned by: | warmerdam |
---|---|---|---|
Priority: | highest | Milestone: | |
Component: | default | Version: | 1.8.0 |
Severity: | normal | Keywords: | GDAL 1.8.0, Chinese |
Cc: |
Description (last modified by )
Dear Sir,
I have been using the GDAL library for several years. As far as I know, it is really the best translator library for raster geospatial data formats. It is very lucky for me to have such an excellent product. I really admire your contributive work. But I have encountered a serious bug in the GDAL 1.8.0 version when I tried to open an image file in Chinese. The problem is described as follows. The test program can be found in the attached files. Please give me some advice. Thank you very much. By the way, I think it would be better that if you provide an overloading edition accepting a UNICODE filename for the function of "GDALOpen()". After all, internationalization is so popular that a filename cannot be presented only with ANSI character set. As is well known, Windows 2000 and later version operating system treat all of the texts as UNICODE characters natively. Thus, it would be more efficient if we use UNICODE characters handle filenames.
Yours Sincerely,
David Hopper (He Zhiguo)
Bug description:
- In GDALTest.cpp main():
poDataset = (GDALDataset *) GDALOpen( pszFilename, GA_ReadOnly );
- In gcore/gdaldataset.cpp GDALOpen():
return GDALOpenInternal(pszFilename, eAccess, NULL);
- In gcore/gdaldataset.cpp GDALOpenInternal():
GDALOpenInfo oOpenInfo( pszFilename, eAccess );
- In gcore/gdalopeninfo.cpp GDALOpenInfo::GDALOpenInfo():
if( VSIStatExL( pszFilename, &sStat,
VSI_STAT_EXISTS_FLAG | VSI_STAT_NATURE_FLAG ) == 0 )
- In port/cpl_vsil.cpp VSIStatExL():
return poFSHandler->Stat( pszFilename, psStatBuf, nFlags );
- in port/cpl_vsil_win32.cpp VSIWin32FilesystemHandler::Stat():
MSVCRT_VERSION >= 0x0601 |
if( CSLTestBoolean(
CPLGetConfigOption( "GDAL_FILENAME_IS_UTF8", "YES" ) ) )
{
int nResult; wchar_t *pwszFilename =
CPLRecodeToWChar( pszFilename, CPL_ENC_UTF8, CPL_ENC_UCS2 );
nResult = _wstat64( pwszFilename, pStatBuf ); CPLFree( pwszFilename ); return nResult;
} else
#endif
The CPLRecodeToWChar () function failed to convert a Chinese filename with multibyte character set to one with UNICODE character set. The following is the description of the CPLRecodeToWChar () function:
Convert a 8bit, multi-byte per character input string into a wide character (wchar_t) string. The only guaranteed supported source encodings are CPL_ENC_UTF8, CPL_ENC_ASCII and CPL_ENC_ISO8869_1 (LATIN1). The only guaranteed supported destination encoding is CPL_ENC_UCS2. Other source and destination encodings may be supported depending on the underlying implementation.
Attachments (2)
Change History (6)
by , 13 years ago
Attachment: | GDALTest.2.zip added |
---|
by , 13 years ago
Attachment: | GDALTest.zip added |
---|
comment:1 by , 13 years ago
Description: | modified (diff) |
---|
comment:2 by , 13 years ago
comment:3 by , 13 years ago
Version: | unspecified → 1.8.0 |
---|
comment:4 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Yes, I've checked that your cpp test file and the filename string in it are in one of the GB encodings, not UTF-8. So not a bug
Are the encoding of your cpp test file and the filename passed to GDAL UTF-8 ? If not, that will explain the error because now GDALOpen() expects filenames to be passed as UTF-8 strings.