Skip to content

Commit

Permalink
gyp: update xml string encoding conversion
Browse files Browse the repository at this point in the history
Bug: nodejs/node-gyp#1203
Change-Id: I30d71a2bb3d4b09e7bd9409c3c45c32bd182d736
  • Loading branch information
refack committed May 21, 2017
1 parent a478c1a commit 0ef2637
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pylib/gyp/easy_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import re
import os
import locale


def XmlToString(content, encoding='utf-8', pretty=False):
Expand Down Expand Up @@ -116,6 +117,10 @@ def WriteXmlIfChanged(content, path, encoding='utf-8', pretty=False,
if win32 and os.linesep != '\r\n':
xml_string = xml_string.replace('\n', '\r\n')

default_encoding = locale.getdefaultlocale()[1]
if default_encoding.upper() != encoding.upper():
xml_string = xml_string.decode(default_encoding).encode(encoding)

# Get the old content
try:
f = open(path, 'r')
Expand Down

0 comments on commit 0ef2637

Please sign in to comment.