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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Helper tool that is built and run during a build to pull strings from 5 // Helper tool that is built and run during a build to pull strings from
6 // the GRD files and generate the InfoPlist.strings files needed for 6 // the GRD files and generate the InfoPlist.strings files needed for
7 // Mac OS X app bundles. 7 // Mac OS X app bundles.
8 8
9 #import <Foundation/Foundation.h> 9 #import <Foundation/Foundation.h>
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return resource_pack; 71 return resource_pack;
72 } 72 }
73 73
74 NSString* LoadStringFromDataPack(ui::DataPack* data_pack, 74 NSString* LoadStringFromDataPack(ui::DataPack* data_pack,
75 const char* data_pack_lang, 75 const char* data_pack_lang,
76 uint32_t resource_id, 76 uint32_t resource_id,
77 const char* resource_id_str) { 77 const char* resource_id_str) {
78 NSString* result = nil; 78 NSString* result = nil;
79 base::StringPiece data; 79 base::StringPiece data;
80 if (data_pack->GetStringPiece(resource_id, &data)) { 80 if (data_pack->GetStringPiece(resource_id, &data)) {
81 // Data pack encodes strings as UTF16. 81 // Data pack encodes strings as either UTF8 or UTF16.
82 result = 82 if (data_pack->GetTextEncodingType() == ui::DataPack::UTF8) {
83 [[[NSString alloc] initWithBytes:data.data() 83 result =
84 length:data.length() 84 [[[NSString alloc] initWithBytes:data.data()
85 encoding:NSUTF16LittleEndianStringEncoding] 85 length:data.length()
86 autorelease]; 86 encoding:NSUTF8StringEncoding]
87 autorelease];
88 } else if (data_pack->GetTextEncodingType() == ui::DataPack::UTF16) {
89 result =
90 [[[NSString alloc] initWithBytes:data.data()
91 length:data.length()
92 encoding:NSUTF16LittleEndianStringEncoding]
93 autorelease];
94 } else {
95 fprintf(stderr, "ERROR: requested string %s from binary data pack\n",
96 resource_id_str);
97 exit(1);
98 }
87 } 99 }
88 if (!result) { 100 if (!result) {
89 fprintf(stderr, "ERROR: failed to load string %s for lang %s\n", 101 fprintf(stderr, "ERROR: failed to load string %s for lang %s\n",
90 resource_id_str, data_pack_lang); 102 resource_id_str, data_pack_lang);
91 exit(1); 103 exit(1);
92 } 104 }
93 return result; 105 return result;
94 } 106 }
95 107
96 // Escape quotes, newlines, etc so there are no errors when the strings file 108 // Escape quotes, newlines, etc so there are no errors when the strings file
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"]; 308 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"];
297 if (![strings_file_contents_utf8 writeToFile:output_path 309 if (![strings_file_contents_utf8 writeToFile:output_path
298 atomically:YES]) { 310 atomically:YES]) {
299 fprintf(stderr, "ERROR: Failed to write out '%s'\n", 311 fprintf(stderr, "ERROR: Failed to write out '%s'\n",
300 [output_path UTF8String]); 312 [output_path UTF8String]);
301 exit(1); 313 exit(1);
302 } 314 }
303 } 315 }
304 return 0; 316 return 0;
305 } 317 }
OLDNEW
« 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