public void ___testToUnicode_2() { String t1 = null; String t2 = null; String t3 = null; try { t1 = new String( "\u1403\u14c5\u1555\u1483\u0020\u1403\u14c4\u1483\u144e\u1450\u1466\u0020\u1405\u1583\u1405\u14f0\u1466\u0020\u1403\u14a1\u14d7\u154b\u14aa" .getBytes("utf-8")); t2 = new String( "\u1403\u14c5\u1555\u1483\u0020\u1403\u14c4\u1483\u144e\u1450\u1466\u0020\u1405\u1583\u1405\u14f0\u1466\u0020\u1403\u14a1\u14d7\u154b\u14aa" .getBytes("utf-8")); t3 = new String( "\u1403\u14c5\u1555\u1483\u0020\u1403\u14c4\u1483\u144e\u1450\u1466" .getBytes("utf-8")); } catch (UnsupportedEncodingException e1) { } String targetContent = "Content-Type: text/html; charset=utf-8\n\n<!--END OF HTTP HEADERS-->" .concat( "<html><head><base href=\"file:///" + System.getenv("JAVA_INUKTITUT") + "/unitTests/files_for_tests/testTranslit.html\"><title>Lecture des polices</title>\n") .concat("<link href=\"styles.css\" rel=\"stylesheet\" type=\"text/css\">\n") .concat("<style type=\"text/css\">\n") .concat(".nunac { font-family:nunacom, Verdana, Arial, Helvetica, sans-serif; }\n") .concat("</style>\n</head>\n<body>\n") .concat( "Texte en nunacom: <div id=\"tnunacom\" class=nunac><span style=\"font-family:pigiarniq\">") .concat(t1) .concat("</span></div>\n") .concat( "Texte en naamajut: <div id=\"tnaamajut\" class=\"texte naamajut\"><span style=\"font-family:pigiarniq\">") .concat(t2) .concat("</span></div>\n") .concat( "Texte en Times New Roman: <div id=\"ttimes\" style=\"font-family:Times New Roman, Helvetica;\">inuuvik inuktitut</div>\n") .concat( "Texte en georgia:<br><font id=\"tgeorgia\" face=\"georgia\">inuuvik inuktitut</font>\n") .concat("<p>\n") .concat( "Texte en prosyl: <div class=\"texte prosyl\"><div id=\"tprosyl\"><span style=\"font-family:pigiarniq\">") .concat(t3) .concat("</span></div></div></p>\n") .concat("</body></html>"); NRC_HTMLDocumentByCobra doc = null; try { String lineSeparator = System.getProperty("line.separator"); doc = new NRC_HTMLDocumentByCobra( "file:///" + System.getenv("JAVA_INUKTITUT") + "/unitTests/files_for_tests/testTranslit.html"); ByteArrayOutputStream out = new ByteArrayOutputStream(); doc.toUnicode(out); doc.close(); String content = out.toString(); out.close(); content = content.replaceAll(lineSeparator, "\n"); if (!content.equals(targetContent)) for (int i = 0; i < targetContent.length(); i++) if (content.charAt(i) == targetContent.charAt(i)) System.out.print(content.charAt(i)); else { System.out.println( "'" + content.charAt(i) + "' [" + (int) content.charAt(i) + "] (should have been '" + targetContent.charAt(i) + "' [" + (int) targetContent.charAt(i) + "])"); break; } assertTrue( "Wrong length: '" + content.length() + "' should have been '" + targetContent.length() + "'\n" + StringUtils.difference(targetContent, content), content.length() == targetContent.length()); assertTrue( "Wrong content: " + StringUtils.difference(targetContent, content), content.equals(targetContent)); } catch (Exception e) { e.printStackTrace(); if (doc != null) doc.close(); fail(); } }
public void ___testToUnicode_1() { String t1 = null; String t2 = null; String t3 = null; t1 = new String( "\u157f\u144e\u1550\u14a5\u1405\u1466\u0020\u1405\u140a\u1595\u14c7\u1593\u14c2\u1550\u14a5\u1405\u1466\u0020\n\u146d\u1591\u14ea\u14d5\u1550\u1439\u1550\u14a5\u1595\u14c2\u1483\u0020\u1438\u1550\u14c7\u1405\u144e\u14a7\u1466\u0020\u144e\u146d\u14d5\u1585\u1433\u1466"); t2 = new String( "\u1403\u1483\u15a0\u148d\u14f1\u1595\u14c2\u1472\u14ea\u14da\u1595\u14a5\u1483\u0020\u1405\u152d\u154b\u1483\u14f4\u1583\u1555\u14a1\u152a\u140a\u1550\u1450\u14a5\u1483\u0020\u157f\u144e\u1550\u14a5\u1405\u1466\u0020\n\u1405\u140a\u1595\u14c7\u1593\u14c2\u1550\u14a5\u1405\u158f\u14d0\u14c2\u0020\u14f4\u1585\u146d\u14da\u1405\u1585\u1433\u1585\u0020\u0031\u0030\u0030\u1472\u14f4\u1595\u14c2\u1483\u0020\u14aa\u1483\u1431\u1490\u1583\u1585\u1450\u14a5\u1483\u0020\u1405\u1583\u1405\u14ef\u1405\u14c2\u1470\u152a\u14c2\u1483\u0020\n\u14aa\u1403\u0020\u0037"); t3 = new String( "\u0039\u002c\u0020\u0032\u0030\u0030\u0032\u14a5\u0020\n\u1472\u144e\u14aa\u144e\u1466\u144e\u144e\u14ea\u14d7\u148b\u1466\u0020\u1403\u14c4\u14d5\u14ab\u14c2\u1483\u0020\u1456\u1483\u146f\u140a\u0020\u14c4\u14c7\u158f\u1466\u1455\u0020\u140a\u1450\u1585\u1455\u1405\u152a\u1483\u14f4\u158f\u14d0\u14c4\u1466\u0020\u1438\u1550\u14c7\u1405\u144e\u1483\u14f4\u158f\u14d0\u14c2\u1483\u002e"); String targetContent = "Content-Type: text/html; charset=utf-8\n\n<!--END OF HTTP HEADERS-->" .concat( "<html><head><base href=\"file:///" + System.getenv("JAVA_INUKTITUT") + "/unitTests/files_for_tests/testFontTelling.html\"><title>Test pour la détermination des polices</title></head>\n") .concat("<body>\n") .concat( "<p><font face=\"nunacom\" size=\"3\"><a href=\"story3.html\"><span style=\"font-family:pigiarniq\">") .concat(t1) .concat("</span></a></font> <br>\n") .concat("<font face=\"nunacom\" size=\"2\"><span style=\"font-family:pigiarniq\">") .concat(t2) .concat( "</span><font face=\"Arial, Helvetica, sans-serif\">-</font><span style=\"font-family:pigiarniq\">") .concat(t3) .concat("</span></font><br>\n</p>\n") .concat("</body></html>"); NRC_HTMLDocumentByCobra doc = null; try { String lineSeparator = System.getProperty("line.separator"); doc = new NRC_HTMLDocumentByCobra( "file:///" + System.getenv("JAVA_INUKTITUT") + "/unitTests/files_for_tests/testFontTelling.html"); ByteArrayOutputStream out = new ByteArrayOutputStream(); doc.toUnicode(out); doc.close(); String content = out.toString("utf-8"); out.close(); content = content.replaceAll(lineSeparator, "\n"); if (!content.equals(targetContent)) for (int i = 0; i < targetContent.length(); i++) if (content.charAt(i) == targetContent.charAt(i)) System.out.println( i + " '" + content.charAt(i) + "' [" + (int) content.charAt(i) + "]"); else { System.out.println( "'" + content.charAt(i) + "' [" + (int) content.charAt(i) + "] (should have been '" + targetContent.charAt(i) + "' [" + (int) targetContent.charAt(i) + "])"); break; } assertTrue( "Wrong length: '" + content.length() + "' should have been '" + targetContent.length() + "'\n" + StringUtils.difference(targetContent, content), content.length() == targetContent.length()); assertTrue( "Wrong content: " + StringUtils.difference(targetContent, content), content.equals(targetContent)); } catch (Exception e) { e.printStackTrace(); if (doc != null) doc.close(); fail(); } }