.,'\"[]{}|&()$!";
var charset = this.getDescendantOfName(bXML ? "jsxsetting_xmloutputcharset" : "jsxsetting_outputcharset").getValue();
var testFile = jsx3.ide.getHomeRelativeFile(bXML ? ".tmp.charsettest.xml" : ".tmp.charsettest");
var alerter = this.getAncestorOfType(jsx3.gui.Dialog);
var encphrase = charset ? "the character encoding '" + charset + "'" : "the default character encoding";
var toWrite = null;
if (bXML) {
var d = new jsx3.xml.Document();
d.loadXML("");
d.getRootNode().setAttribute("jsxid", testText);
toWrite = d.serialize(true, charset);
} else {
toWrite = testText + "\n";
}
if (testFile.write(toWrite, {charset:charset})) {
var readText = null;
if (bXML) {
var rd = new jsx3.xml.Document();
rd.load(testFile.toURI());
if (rd.hasError()) {
alerter.alert("Test Failure", "A test file was written using " + encphrase +
" but reading the file caused an error: " + rd.getError());
return;
} else {
readText = rd.getRootNode().getAttribute("jsxid");
}
} else {
readText = jsx3.util.strTrim(testFile.read());
}
if (readText == testText) {
alerter.alert("Test Success", "A test file was successfully written using " + encphrase + ".");
testFile.deleteFile();
} else {
alerter.alert("Test Failure", "A test file was written using " + encphrase +
" but reading the file failed (" + readText + ").");
}
} else {
alerter.alert("Test Failure", "A test file could not be written using " + encphrase +
". Check the system log for a more detailed message.");
}
};
]]>