diff options
author | slall | 2015-03-02 14:56:50 +0000 |
---|---|---|
committer | slall | 2015-03-02 14:56:50 +0000 |
commit | e5c1a39741e2291a43146eb685d61903f74dbfb3 (patch) | |
tree | 22fc332a4a5e7e001a6f1d7ca391ab467c3d3e55 | |
parent | f0a28e418c036c0493e8ccf9c58980c866875417 (diff) | |
download | org.eclipse.rmf-e5c1a39741e2291a43146eb685d61903f74dbfb3.tar.gz org.eclipse.rmf-e5c1a39741e2291a43146eb685d61903f74dbfb3.tar.xz org.eclipse.rmf-e5c1a39741e2291a43146eb685d61903f74dbfb3.zip |
Bug 456675 - modified stream writer to support utf8 file creation.
Change-Id: I0f17562ea8a507b09f5eff2f055db8dcf6c718b6
Signed-off-by: slall <davidlall777@gmail.com>
2 files changed, 8 insertions, 34 deletions
diff --git a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/util/HTMLPrinter.java b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/util/HTMLPrinter.java index c99ae956..3ac7750b 100644 --- a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/util/HTMLPrinter.java +++ b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/util/HTMLPrinter.java @@ -11,8 +11,10 @@ package org.eclipse.rmf.reqif10.pror.editor.util; import java.io.File; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; +import java.nio.charset.Charset; import java.text.SimpleDateFormat; import java.util.GregorianCalendar; import java.util.Iterator; @@ -94,7 +96,7 @@ public class HTMLPrinter { // Write the HTML File htmlFile = new File(targetFolder, spec.getIdentifier() + ".html"); - FileWriter writer = new FileWriter(htmlFile); + OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(htmlFile),Charset.forName("UTF-8").newEncoder()); writer.write(html.toString()); writer.close(); htmlFile.deleteOnExit(); @@ -193,12 +195,12 @@ public class HTMLPrinter { if (content != null) { html.append(content); } else { - html.append(HTMLPrinter.normalizeHtmlString(getValueAsString(av))); + html.append(getValueAsString(av)); } } } else { - html.append(HTMLPrinter.normalizeHtmlString(getValueAsString(av))); + html.append(getValueAsString(av)); } if (first) { @@ -299,32 +301,4 @@ public class HTMLPrinter { return textValue; } - - /** - * O.T.G.O.T.L.J.C. - david lall - * @Bugfix 456675 - * Normalize a string using decimal code to render non-english language characters in html. - * @param inputStr - */ - public static String normalizeHtmlString(String inputStr){ - //1. Parameter condition check. - if(inputStr==null || inputStr.trim().length()==0) - return ""; - - //2. Convert each char of input string to its decimal code & apply formatting. - StringBuilder htmlString = new StringBuilder(); - inputStr=inputStr.trim(); - for(int i=0;i<inputStr.length();i++){ - int decimalValue=(int)inputStr.charAt(i); - if((decimalValue>=48 && decimalValue<=57) || (decimalValue>=65 && decimalValue<=90) || (decimalValue>=97 && decimalValue<=122)){ - htmlString.append((char)decimalValue); - }//end of if - else{ - htmlString.append("&#"+decimalValue+";"); - }//end of else - }//end of for - - return htmlString.toString(); - }//end of method - } diff --git a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/util/ProrEditorUtil.java b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/util/ProrEditorUtil.java index 58e95d35..0e8ea487 100644 --- a/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/util/ProrEditorUtil.java +++ b/org.eclipse.rmf.reqif10.pror.editor/src/org/eclipse/rmf/reqif10/pror/editor/util/ProrEditorUtil.java @@ -160,12 +160,12 @@ public class ProrEditorUtil { if (content != null) {
html.append(content);
} else {
- html.append(HTMLPrinter.normalizeHtmlString(getDefaultValue(av)));
+ html.append(getDefaultValue(av));
}
}
} else {
- html.append(HTMLPrinter.normalizeHtmlString(getDefaultValue(av)));
+ html.append(getDefaultValue(av));
}
if (first) {
|