Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick and dirty fix to allow WriteXmlIfChanged to write xml in utf-8, co... #366

Closed
wants to merge 2 commits into from

Conversation

jfhenriques
Copy link
Contributor

This is a quick and dirty fix to allow node-gyp to generate the vcxproj when the are latin-1 characters in the paths.

I'm not a python programmer, this just solved the problem I had with latin-1 characters..

WriteXmlIfChanged was not actually writing in utf-8, but in ascii. Converting directly to utf-8 would fail if unicode(string, native_enconding) is not called first.

@TooTallNate
Copy link
Contributor

Can you propose this on the gyp issue tracker instead? I don't want to have to float more gyp patches than necessary.

@jfhenriques
Copy link
Contributor Author

Better handling of encoding
@jfhenriques
Copy link
Contributor Author

To my surprise this is not yet fixed.

Today I updated npm and node, so I needed to redo the "fix".

To anyone who has the same problem, the solution is simple.

In your node installation directory (mine was "C:\Program Files (x86)\nodejs")

Edit this file (in Windows 8, I needed to edit as admin) "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\easy_xml.py"

Search for this piece of code:

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

and change to

  # 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()

"latin-1" needs to be changed to the proper encoding for this to work. For Portuguese language "latin-1" works great.

@venca163
Copy link

thank you for the fix

@eTorAken
Copy link

Seems it is not fixed yet in node-gyp@1.0.3

@Sogl
Copy link

Sogl commented Apr 30, 2015

Not fixed yet =(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants