提交 b239f94c authored 作者: Thomas Mueller's avatar Thomas Mueller

The SCRIPT command and tool now uses the default file encoding for the system…

The SCRIPT command and tool now uses the default file encoding for the system now instead of UTF-8 (as before).
上级 d32dc612
...@@ -61,6 +61,7 @@ import org.h2.value.ValueString; ...@@ -61,6 +61,7 @@ import org.h2.value.ValueString;
*/ */
public class ScriptCommand extends ScriptBase { public class ScriptCommand extends ScriptBase {
private String charset = SysProperties.FILE_ENCODING;
private boolean passwords; private boolean passwords;
private boolean data; private boolean data;
private boolean settings; private boolean settings;
...@@ -530,7 +531,11 @@ public class ScriptCommand extends ScriptBase { ...@@ -530,7 +531,11 @@ public class ScriptCommand extends ScriptBase {
private void reset() { private void reset() {
result = null; result = null;
buffer = null; buffer = null;
lineSeparator = StringUtils.utf8Encode(SysProperties.LINE_SEPARATOR); try {
lineSeparator = SysProperties.LINE_SEPARATOR.getBytes(charset);
} catch (IOException e) {
throw DbException.convertIOException(e, null);
}
} }
private void add(String s, boolean insert) throws IOException { private void add(String s, boolean insert) throws IOException {
...@@ -539,7 +544,7 @@ public class ScriptCommand extends ScriptBase { ...@@ -539,7 +544,7 @@ public class ScriptCommand extends ScriptBase {
} }
s += ";"; s += ";";
if (out != null) { if (out != null) {
byte[] buff = StringUtils.utf8Encode(s); byte[] buff = s.getBytes(charset);
int len = MathUtils.roundUpInt(buff.length + lineSeparator.length, Constants.FILE_BLOCK_SIZE); int len = MathUtils.roundUpInt(buff.length + lineSeparator.length, Constants.FILE_BLOCK_SIZE);
buffer = Utils.copy(buff, buffer); buffer = Utils.copy(buff, buffer);
...@@ -568,4 +573,8 @@ public class ScriptCommand extends ScriptBase { ...@@ -568,4 +573,8 @@ public class ScriptCommand extends ScriptBase {
this.simple = simple; this.simple = simple;
} }
public void setCharset(String charset) {
this.charset = charset;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论