* sourceCharset property patch contributed by kunitoki at gmail on helma-user
This commit is contained in:
parent
972bb8f232
commit
d8f5446d01
2 changed files with 17 additions and 10 deletions
|
@ -28,22 +28,25 @@ import java.util.StringTokenizer;
|
|||
*/
|
||||
public class HacHspConverter {
|
||||
|
||||
public static String convertHac(Resource action) throws IOException {
|
||||
public static String convertHac(Resource action, String encoding)
|
||||
throws IOException {
|
||||
String functionName = action.getBaseName().replace('.', '_') + "_action";
|
||||
return composeFunction(functionName, null, action.getContent());
|
||||
return composeFunction(functionName, null, action.getContent(encoding));
|
||||
}
|
||||
|
||||
public static String convertHsp(Resource template) throws IOException {
|
||||
public static String convertHsp(Resource template, String encoding)
|
||||
throws IOException {
|
||||
String functionName = template.getBaseName().replace('.', '_');
|
||||
String body = processHspBody(template.getContent());
|
||||
String body = processHspBody(template.getContent(encoding));
|
||||
return composeFunction(functionName,
|
||||
"arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10",
|
||||
body);
|
||||
}
|
||||
|
||||
public static String convertHspAsString(Resource template) throws IOException {
|
||||
public static String convertHspAsString(Resource template, String encoding)
|
||||
throws IOException {
|
||||
String functionName = template.getBaseName().replace('.', '_') + "_as_string";
|
||||
String body = processHspBody(template.getContent());
|
||||
String body = processHspBody(template.getContent(encoding));
|
||||
return composeFunction(functionName,
|
||||
"arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10",
|
||||
"res.pushStringBuffer(); " + body +
|
||||
|
|
|
@ -769,19 +769,23 @@ public final class RhinoCore implements ScopeProvider {
|
|||
Resource previousCurrentResource = app.getCurrentCodeResource();
|
||||
app.setCurrentCodeResource(code);
|
||||
|
||||
String encoding = app.getProperty("sourceCharset");
|
||||
|
||||
try {
|
||||
Scriptable op = type.objProto;
|
||||
// do the update, evaluating the file
|
||||
if (sourceName.endsWith(".js")) {
|
||||
reader = new InputStreamReader(code.getInputStream());
|
||||
reader = encoding == null ?
|
||||
new InputStreamReader(code.getInputStream()) :
|
||||
new InputStreamReader(code.getInputStream(), encoding);
|
||||
cx.evaluateReader(op, reader, sourceName, 1, null);
|
||||
} else if (sourceName.endsWith(".hac")) {
|
||||
reader = new StringReader(HacHspConverter.convertHac(code));
|
||||
reader = new StringReader(HacHspConverter.convertHac(code, encoding));
|
||||
cx.evaluateReader(op, reader, sourceName, 0, null);
|
||||
} else if (sourceName.endsWith(".hsp")) {
|
||||
reader = new StringReader(HacHspConverter.convertHsp(code));
|
||||
reader = new StringReader(HacHspConverter.convertHsp(code, encoding));
|
||||
cx.evaluateReader(op, reader, sourceName, 0, null);
|
||||
reader = new StringReader(HacHspConverter.convertHspAsString(code));
|
||||
reader = new StringReader(HacHspConverter.convertHspAsString(code, encoding));
|
||||
cx.evaluateReader(op, reader, sourceName, 0, null);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue