| Index: tools/grit/grit/format/data_pack.py
|
| diff --git a/tools/grit/grit/format/data_pack.py b/tools/grit/grit/format/data_pack.py
|
| index 993ecf63fd127f3709eb5c26500cb366ebc209d1..67c6f78a3774dd382263cd3b90cafb8b9bc06486 100755
|
| --- a/tools/grit/grit/format/data_pack.py
|
| +++ b/tools/grit/grit/format/data_pack.py
|
| @@ -15,8 +15,10 @@ from grit.node import message
|
| from grit.node import misc
|
|
|
|
|
| -PACK_FILE_VERSION = 3
|
| -
|
| +PACK_FILE_VERSION = 4
|
| +BINARY = 0
|
| +UTF8 = 1
|
| +UTF16 = 2
|
|
|
| class DataPack(interface.ItemFormatter):
|
| '''Writes out the data pack file format (platform agnostic resource file).'''
|
| @@ -29,9 +31,9 @@ class DataPack(interface.ItemFormatter):
|
| nodes = DataPack.GetDataNodes(item)
|
| data = {}
|
| for node in nodes:
|
| - id, value = node.GetDataPackPair(lang)
|
| + id, value = node.GetDataPackPair(lang, UTF8)
|
| data[id] = value
|
| - return DataPack.WriteDataPack(data)
|
| + return DataPack.WriteDataPack(data, UTF8)
|
|
|
| @staticmethod
|
| def GetDataNodes(item):
|
| @@ -50,15 +52,15 @@ class DataPack(interface.ItemFormatter):
|
| return nodes
|
|
|
| @staticmethod
|
| - def WriteDataPack(resources):
|
| + def WriteDataPack(resources, encoding):
|
| """Write a map of id=>data into a string in the data pack format and return
|
| it."""
|
| ids = sorted(resources.keys())
|
| ret = []
|
|
|
| # Write file header.
|
| - ret.append(struct.pack("<II", PACK_FILE_VERSION, len(ids)))
|
| - HEADER_LENGTH = 2 * 4 # Two uint32s.
|
| + ret.append(struct.pack("<III", PACK_FILE_VERSION, len(ids), encoding))
|
| + HEADER_LENGTH = 3 * 4 # Three uint32s.
|
|
|
| # Each entry is a uint16 + a uint32s. We have one extra entry for the last
|
| # item.
|
|
|