Fix for Unicode chars being mangled when building.

Closes #146.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I committed 2009-05-27 01:34:56 -07:00
1 parent bf21fbd000
commit 5cb9f5f7c2
5 files changed
+18 -32

No files matched your search

+3 -3
View File
@@ -88,7 +88,7 @@ function main()
temporaryCibFile = Packages.java.io.File.createTempFile("temp", ".cib"),
temporaryCibFilePath = String(temporaryCibFile.getAbsolutePath());
File.write(temporaryCibFilePath, [data string], { charset:"UTF8" });
File.write(temporaryCibFilePath, [data string], { charset:"UTF-8" });
cibFiles.push(temporaryCibFilePath);
}
@@ -171,8 +171,8 @@ function buildBlendFromCibFiles(cibFiles, outputFilePath, resourcesPath)
outputFile.mkdirs();
File.write(outputFilePath + "/Info.plist", [CPPropertyListCreate280NorthData(infoDictionary) string], { charset:"UTF8" });
File.write(outputFilePath + '/' + staticContentName, staticContent, { charset:"UTF8" });
File.write(outputFilePath + "/Info.plist", [CPPropertyListCreate280NorthData(infoDictionary) string], { charset:"UTF-8" });
File.write(outputFilePath + '/' + staticContentName, staticContent, { charset:"UTF-8" });
if (resourcesPath)
rsync(new Packages.java.io.File(resourcesPath), new Packages.java.io.File(outputFilePath));
+10 -24
View File
@@ -1,15 +1,14 @@
#!/usr/bin/env narwhal
var objjc = require("objj/objjc");
var objjc = require("objj/objjc"),
File = require("file");
with (objjc)
{
importPackage(java.lang);
importClass(java.io.BufferedReader);
importClass(java.io.FileReader);
importClass(java.io.BufferedWriter);
importClass(java.io.FileWriter);
OBJJ_PREPROCESSOR_PREPROCESS = 1 << 10;
@@ -22,7 +21,7 @@ function exec(/*Array*/ command, /*Boolean*/ showOutput)
output = "",
process = Packages.java.lang.Runtime.getRuntime().exec(command),//jsArrayToJavaArray(command));
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getInputStream()));
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getInputStream(), "UTF-8"));
while (line = reader.readLine())
{
@@ -32,7 +31,7 @@ function exec(/*Array*/ command, /*Boolean*/ showOutput)
output += line + '\n';
}
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getErrorStream()));
reader = new Packages.java.io.BufferedReader(new Packages.java.io.InputStreamReader(process.getErrorStream(), "UTF-8"));
while (line = reader.readLine())
System.out.println(line);
@@ -52,13 +51,9 @@ function exec(/*Array*/ command, /*Boolean*/ showOutput)
function compress(/*String*/ aCode, /*Object*/ flags, /*File*/ tmpFile)
{
var writer = new BufferedWriter(new FileWriter(tmpFile));
writer.write(aCode);
writer.close();
File.write(tmpFile, aCode, { charset:"UTF-8" });
return exec(["java", "-classpath", OBJJ_HOME + "/lib/js.jar" + ":" + OBJJ_HOME + "/lib/shrinksafe.jar", "org.dojotoolkit.shrinksafe.Main", tmpFile.getCanonicalPath(), "-escape-unicode"]);
return exec(["java", "-Dfile.encoding=UTF-8", "-classpath", OBJJ_HOME + "/lib/js.jar" + ":" + OBJJ_HOME + "/lib/shrinksafe.jar", "org.dojotoolkit.shrinksafe.Main", tmpFile.getCanonicalPath()]);
}
//#define SET_CONTEXT(aFragment, aContext) aFragment.context = aContext
@@ -112,15 +107,8 @@ function preprocess(aFilePath, outFilePath, gccArgs, flags)
return;
// Read file and preprocess it.
var reader = new BufferedReader(new FileReader(tmpFile)),
fileContents = "";
// Get contents of the file
while (reader.ready())
fileContents += reader.readLine() + '\n';
reader.close();
var fileContents = File.read(tmpFile, { charset: "UTF-8" });
// Preprocess contents into fragments.
var filePath = new String(new java.io.File(aFilePath).getName()),
fragments = objj_preprocess(fileContents, { path:"/x" }, {path:filePath}, flags),
@@ -171,9 +159,7 @@ function preprocess(aFilePath, outFilePath, gccArgs, flags)
}
// Write file.
var writer = new BufferedWriter(new FileWriter(outFilePath));
writer.write(preprocessed);
writer.close();
File.write(outFilePath, preprocessed, { charset: "UTF-8" });
}
function main()
+1 -1
View File
@@ -14,7 +14,7 @@ window.args = system.args;
with (window)
{
eval(File.read(OBJJ_HOME+"/lib/Frameworks/Objective-J/rhino.platform/Objective-J.js", { charset : "UTF-8" }));
eval(File.read(OBJJ_HOME + "/lib/Frameworks/Objective-J/rhino.platform/Objective-J.js", { charset:"UTF-8" }));
if (system.args.length > 0)
{
+1 -1
View File
@@ -10,7 +10,7 @@ var OBJJ_HOME = system.prefix + "/..";
with (window)
{
eval(File.read(OBJJ_HOME+"/lib/Frameworks/Objective-J/rhino.platform/Objective-J.js").toString());
eval(File.read(OBJJ_HOME + "/lib/Frameworks/Objective-J/rhino.platform/Objective-J.js", { charset:"UTF-8" }).toString());
for (var i = 0; i < exported.length; i++)
exports[exported[i]] = eval(exported[i]);
+3 -3
View File
@@ -125,7 +125,7 @@ function convert(inputFileName, outputFileName, resourcesPath)
return;
}
var data = [CPData dataWithString:File.read(String(temporaryPlistFilePath), { charset:"UTF8" })];
var data = [CPData dataWithString:File.read(String(temporaryPlistFilePath), { charset:"UTF-8" })];
// Minor NSKeyedArchive to CPKeyedArchive conversion.
[data setString:[data string].replace(/\<key\>\s*CF\$UID\s*\<\/key\>/g, "<key>CP$UID</key>")];
@@ -141,7 +141,7 @@ function convert(inputFileName, outputFileName, resourcesPath)
[archiver encodeObject:objectData forKey:@"CPCibObjectDataKey"];
[archiver finishEncoding];
File.write(outputFileName, [data string], { charset:"UTF8" });
File.write(outputFileName, [data string], { charset:"UTF-8" });
}
function loadFrameworks(frameworkPaths, aCallback)
@@ -159,7 +159,7 @@ function loadFrameworks(frameworkPaths, aCallback)
java.lang.System.exit(1);
}
var infoDictionary = CPPropertyListCreateFromData([CPData dataWithString:File.read(frameworkPath + "/Info.plist", { charset:"UTF8" })]);
var infoDictionary = CPPropertyListCreateFromData([CPData dataWithString:File.read(frameworkPath + "/Info.plist", { charset:"UTF-8" })]);
if ([infoDictionary objectForKey:@"CPBundlePackageType"] !== "FMWK")
{