tsekityam / gyp

Automatically exported from code.google.com/p/gyp
0 stars 0 forks source link

Allow latin-1 character encoding in user directory #393

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. using node-gyp on any system where the user name has latin-1 characters
2.
3.

What is the expected output? What do you see instead?
to generate the .vcxproj in UTF-8 encoding (currently is in ASCII)

What version of the product are you using? On what operating system?
0.12.1 on Windows 8.1

Please provide any additional information below.
WriteXmlIfChanged on pylib/gyp/easy_xml.py actually output to ascii encoding. 
Converting directly to utf-8 fails, so unidecode needs to be used first.

This path was a very quick fix that works for me, but more work needs to be 
done, like detecting the native enconding ro something like that. In may case 
it was latin-1, but it might be others.

Original issue reported on code.google.com by joaoh88 on 12 Dec 2013 at 4:41

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry it was unicode not unidecode

Original comment by joaoh88 on 12 Dec 2013 at 4:46

GoogleCodeExporter commented 9 years ago
This simple patch solves the problem when building on windows with usernames 
with non-ascii letters.

On the file  pylib/gyp/easy_xml.py

Simply find this pieace of code

  # It has changed, write it
  if existing != xml_string:
    f = open(path, 'w')
    f.write(xml_string)
    f.close()

and change to something like this:

  # It has changed, write it
  if existing != xml_string:
    f = open(path, 'w')
    try:
      xml_string = xml_string.encode(encoding)
    except Exception:
      xml_string = unicode(xml_string, 'latin-1').encode(encoding)
    f.write(xml_string)
    f.close()

Original comment by joaoh88 on 28 Jun 2014 at 3:45