| 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..3c5ac645f1137a4b75a5d49a99808601fbb081f3 100644
|
| --- a/tools/grit/grit/node/message.py
|
| +++ b/tools/grit/grit/node/message.py
|
| @@ -1,5 +1,5 @@
|
| #!/usr/bin/python2.4
|
| -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
| +# Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| @@ -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):
|
|
|