use of org.eclipse.wst.css.core.internal.contenttype.CSSResourceEncodingDetector in project webtools.sourceediting by eclipse.
the class CSSEncodingTester method testJIS.
public void testJIS() throws IOException {
String filename = fileLocation + "encoding_test_jis.css";
doTestFileStream(filename, "ISO-2022-JP", new CSSResourceEncodingDetector());
}
use of org.eclipse.wst.css.core.internal.contenttype.CSSResourceEncodingDetector in project webtools.sourceediting by eclipse.
the class CSSEncodingTester method testUTF16leMalformed.
public void testUTF16leMalformed() throws IOException {
String filename = fileLocation + "utf16leMalformed.css";
doTestFileStream(filename, "UTF-16LE", new CSSResourceEncodingDetector());
}
use of org.eclipse.wst.css.core.internal.contenttype.CSSResourceEncodingDetector in project webtools.sourceediting by eclipse.
the class CSSEncodingTester method testEUCJP.
public void testEUCJP() throws IOException {
String filename = fileLocation + "encoding_test_eucjp.css";
doTestFileStream(filename, "EUC-JP", new CSSResourceEncodingDetector());
}
use of org.eclipse.wst.css.core.internal.contenttype.CSSResourceEncodingDetector in project webtools.sourceediting by eclipse.
the class CSSEncodingTester method doTestFileStream.
private void doTestFileStream(String filename, String expectedIANAEncoding, IResourceCharsetDetector detector) throws IOException {
File file = CSSEncodingTestsPlugin.getTestFile(filename);
if (!file.exists())
throw new IllegalArgumentException(filename + " was not found");
InputStream inputStream = new FileInputStream(file);
// InputStream inStream = getClass().getResourceAsStream(filename);
InputStream istream = getMarkSupportedStream(inputStream);
try {
detector.set(istream);
EncodingMemento encodingMemento = ((CSSResourceEncodingDetector) detector).getEncodingMemento();
String foundIANAEncoding = null;
if (encodingMemento != null) {
foundIANAEncoding = encodingMemento.getDetectedCharsetName();
}
// I changed many "equals" to "equalsIgnoreCase" on 11/4/2002,
// since
// some issues with SHIFT_JIS vs. Shift_JIS were causing failures.
// We do want to be tolerant on input, and accept either, but I
// think
// that SupportedJavaEncodings needs to be changed to "recommend"
// Shift_JIS.
boolean expectedIANAResult = false;
if (expectedIANAEncoding == null) {
expectedIANAResult = expectedIANAEncoding == foundIANAEncoding;
} else {
expectedIANAResult = expectedIANAEncoding.equalsIgnoreCase(foundIANAEncoding);
}
assertTrue("encoding test file " + filename + " expected: " + expectedIANAEncoding + " found: " + foundIANAEncoding, expectedIANAResult);
// throws exception.
if (foundIANAEncoding != null) {
ensureCanRead(filename, foundIANAEncoding, istream);
}
} finally {
if (istream != null) {
istream.close();
}
if (inputStream != null) {
inputStream.close();
}
}
}
use of org.eclipse.wst.css.core.internal.contenttype.CSSResourceEncodingDetector in project webtools.sourceediting by eclipse.
the class CSSEncodingTester method testnonStandardIllFormed2.
public void testnonStandardIllFormed2() throws IOException {
String filename = fileLocation + "nonStandardIllFormed2.css";
doTestFileStream(filename, "ISO-8859-6", new CSSResourceEncodingDetector());
}
Aggregations