Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: tools/grit/grit/format/data_pack.py

Issue 7744017: Updated *.pak file format to support both UTF8 and UTF16 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..e8d88077f56a818957f967ec419d911878a7bc68 100755
--- a/tools/grit/grit/format/data_pack.py
+++ b/tools/grit/grit/format/data_pack.py
@@ -15,8 +15,8 @@ from grit.node import message
from grit.node import misc
-PACK_FILE_VERSION = 3
-
+PACK_FILE_VERSION = 4
+BINARY, UTF8, UTF16 = range(3)
class DataPack(interface.ItemFormatter):
'''Writes out the data pack file format (platform agnostic resource file).'''
@@ -29,9 +29,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 +50,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("<IIB", PACK_FILE_VERSION, len(ids), encoding))
+ HEADER_LENGTH = 2 * 4 + 1 # Two uint32s and one uint8.
# Each entry is a uint16 + a uint32s. We have one extra entry for the last
# item.

Powered by Google App Engine
This is Rietveld 408576698