MantisBT - CMake
View Issue Details
0012075CMakeCMakepublic2011-04-13 04:362015-06-01 08:38
zouguangxian 
Clinton Stimpson 
highmajoralways
closedfixed 
Windows
 
CMake 3.2 
0012075: generated .vcproj with wrong encoding
for example, in Source\cmGlobalVisualStudio7Generator.cxx:
line 636
//----------------------------------------------------------------------------
std::string
cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget* target)
{
  std::string pname = target->GetName();
  pname += "_UTILITY";
  std::string fname = target->GetMakefile()->GetStartOutputDirectory();
  fname += "/";
  fname += pname;
  fname += ".vcproj";
  cmGeneratedFileStream fout(fname.c_str());
  fout.SetCopyIfDifferent(true);
  this->CreateGUID(pname.c_str());
  std::string guid = this->GetGUID(pname.c_str());

  fout <<
    "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"

the encoding always be "Windows-1252", but if the path include chinese characteres, the generated .vcproj can't be open correctly in Visual Studio.

the solution is:
1. determine the codepage
2. set the correct encoding.

like the following:

  std::string guid = this->GetGUID(pname.c_str());

  std::string encoding = "Windows-1252";
  switch(_getmbcp())
  {
  case 936:
      encoding = "gb2312";
      break;
  default:
      break;
  }
  fout <<
    "<?xml version=\"1.0\" encoding = \"" << encoding << "\"?>\n"
No tags attached.
related to 0010180closed Clinton Stimpson CMake won't generate Visual Studio projects with working paths that have Unicode charactors 
related to 0012074closed Clinton Stimpson "Could not copy from" On Windows 7 (Simplified Chinese) 
Issue History
2011-04-13 04:36zouguangxianNew Issue
2012-02-23 21:26zouguangxianNote Added: 0028705
2012-02-24 08:29Brad KingRelationship addedrelated to 0010180
2012-02-24 08:30Brad KingRelationship addedrelated to 0012074
2012-02-24 08:42Brad KingNote Added: 0028711
2012-02-24 08:42Brad KingStatusnew => backlog
2015-01-15 23:41Clinton StimpsonAssigned To => Clinton Stimpson
2015-01-15 23:41Clinton StimpsonStatusbacklog => assigned
2015-01-16 10:12Clinton StimpsonNote Added: 0037717
2015-01-16 10:12Clinton StimpsonStatusassigned => resolved
2015-01-16 10:12Clinton StimpsonFixed in Version => CMake 3.2
2015-01-16 10:12Clinton StimpsonResolutionopen => fixed
2015-06-01 08:38Robert MaynardNote Added: 0038843
2015-06-01 08:38Robert MaynardStatusresolved => closed

Notes
(0028705)
zouguangxian   
2012-02-23 21:26   
It is duplication of 0005097, 0010180.
(0028711)
Brad King   
2012-02-24 08:42   
The encoding of generated project files will also have to be honored in the rest of the generator to actually write out a byte stream of characters using that encoding. See 0012074:0028710.
(0037717)
Clinton Stimpson   
2015-01-16 10:12   
Fixed by switching to utf-8 internally.
http://www.cmake.org/gitweb?p=cmake.git;a=commit;h=cdc29c3 [^]
(0038843)
Robert Maynard   
2015-06-01 08:38   
Closing resolved issues that have not been updated in more than 4 months.