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

Unified Diff: chrome/tools/mac_helpers/infoplist_strings_util.mm

Issue 7744017: Updated *.pak file format to support both UTF8 and UTF16 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modified mac-specific parts of the code. Created 9 years, 3 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
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.cc ('k') | chrome_frame/simple_resource_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/tools/mac_helpers/infoplist_strings_util.mm
diff --git a/chrome/tools/mac_helpers/infoplist_strings_util.mm b/chrome/tools/mac_helpers/infoplist_strings_util.mm
index 469af2ebd9dfd17a2cc71529bb030376ecdcc102..935b5317539b19705b243d519c6595ede3449d26 100644
--- a/chrome/tools/mac_helpers/infoplist_strings_util.mm
+++ b/chrome/tools/mac_helpers/infoplist_strings_util.mm
@@ -78,12 +78,24 @@ NSString* LoadStringFromDataPack(ui::DataPack* data_pack,
NSString* result = nil;
base::StringPiece data;
if (data_pack->GetStringPiece(resource_id, &data)) {
- // Data pack encodes strings as UTF16.
- result =
- [[[NSString alloc] initWithBytes:data.data()
- length:data.length()
- encoding:NSUTF16LittleEndianStringEncoding]
- autorelease];
+ // Data pack encodes strings as either UTF8 or UTF16.
+ if (data_pack->GetTextEncodingType() == ui::DataPack::UTF8) {
+ result =
+ [[[NSString alloc] initWithBytes:data.data()
+ length:data.length()
+ encoding:NSUTF8StringEncoding]
+ autorelease];
+ } else if (data_pack->GetTextEncodingType() == ui::DataPack::UTF16) {
+ result =
+ [[[NSString alloc] initWithBytes:data.data()
+ length:data.length()
+ encoding:NSUTF16LittleEndianStringEncoding]
+ autorelease];
+ } else {
+ fprintf(stderr, "ERROR: requested string %s from binary data pack\n",
+ resource_id_str);
+ exit(1);
+ }
}
if (!result) {
fprintf(stderr, "ERROR: failed to load string %s for lang %s\n",
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.cc ('k') | chrome_frame/simple_resource_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698