| Index: tools/grit/grit/node/message.py
|
| diff --git a/tools/grit/grit/node/message.py b/tools/grit/grit/node/message.py
|
| index a48a645fd4ba2ce489bf2c6794f4b6c751539c73..0d252c11b9116c5144e1ee42e515f31ca8613173 100644
|
| --- a/tools/grit/grit/node/message.py
|
| +++ b/tools/grit/grit/node/message.py
|
| @@ -19,6 +19,7 @@ from grit import exception
|
| from grit import tclib
|
| from grit import util
|
|
|
| +BINARY, UTF8, UTF16 = range(3)
|
|
|
| # Finds whitespace at the start and end of a string which can be multiline.
|
| _WHITESPACE = re.compile('(?P<start>\s*)(?P<body>.+?)(?P<end>\s*)\Z',
|
| @@ -186,7 +187,7 @@ class MessageNode(base.ContentNode):
|
| else:
|
| return self.attrs['offset']
|
|
|
| - def GetDataPackPair(self, lang):
|
| + def GetDataPackPair(self, lang, encoding):
|
| '''Returns a (id, string) pair that represents the string id and the string
|
| in utf8. This is used to generate the data pack data file.
|
| '''
|
| @@ -199,10 +200,15 @@ class MessageNode(base.ContentNode):
|
| # Windows automatically translates \n to a new line, but GTK+ doesn't.
|
| # Manually do the conversion here rather than at run time.
|
| message = message.replace("\\n", "\n")
|
| - # |message| is a python unicode string, so convert to a utf16 byte stream
|
| - # because that's the format of datapacks. We skip the first 2 bytes
|
| - # because it is the BOM.
|
| - return id, message.encode('utf16')[2:]
|
| + # |message| is a python unicode string, so convert to a byte stream that
|
| + # has the correct encoding requested for the datapacks. We skip the first
|
| + # 2 bytes of text resources because it is the BOM.
|
| + if encoding == UTF8:
|
| + return id, message.encode('utf8')
|
| + if encoding == UTF16:
|
| + return id, message.encode('utf16')[2:]
|
| + # Default is BINARY
|
| + return id, message
|
|
|
| # static method
|
| def Construct(parent, message, name, desc='', meaning='', translateable=True):
|
|
|