aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-common/src')
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java18
-rw-r--r--pdf-as-common/src/test/java/at/gv/egiz/pdfas/common/test/utils/StringUtilsTest.java22
2 files changed, 35 insertions, 5 deletions
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java
index 7156a97b..70344f78 100644
--- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java
+++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/StringUtils.java
@@ -23,13 +23,13 @@
******************************************************************************/
package at.gv.egiz.pdfas.common.utils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Formatter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Created with IntelliJ IDEA. User: afitzek Date: 8/28/13 Time: 12:42 PM To
* change this template use File | Settings | File Templates.
@@ -38,6 +38,7 @@ public class StringUtils {
private static final Logger logger = LoggerFactory
.getLogger(StringUtils.class);
+ private static final CharSequence TABULATOR = '\u0009'+"";
public static String bytesToHexString(byte[] bytes) {
StringBuilder sb = new StringBuilder(bytes.length * 2);
@@ -75,10 +76,17 @@ public class StringUtils {
// Cannot encode String with CP1252 have to use URL encoding ...
return URLEncoder.encode(value, "UTF-8");
}
- return value;
+
+ return replaceSpecialCharacters(value);
+
}
- public static byte[] applyWinAnsiEncoding(String text)
+ private static String replaceSpecialCharacters(String value) {
+ return value.replace(TABULATOR, " ");
+
+ }
+
+ public static byte[] applyWinAnsiEncoding(String text)
throws UnsupportedEncodingException {
byte[] replace_bytes;
replace_bytes = text.getBytes("windows-1252");// CP1252 =
diff --git a/pdf-as-common/src/test/java/at/gv/egiz/pdfas/common/test/utils/StringUtilsTest.java b/pdf-as-common/src/test/java/at/gv/egiz/pdfas/common/test/utils/StringUtilsTest.java
new file mode 100644
index 00000000..6c6ee654
--- /dev/null
+++ b/pdf-as-common/src/test/java/at/gv/egiz/pdfas/common/test/utils/StringUtilsTest.java
@@ -0,0 +1,22 @@
+package at.gv.egiz.pdfas.common.test.utils;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.UnsupportedEncodingException;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.BlockJUnit4ClassRunner;
+
+import at.gv.egiz.pdfas.common.utils.StringUtils;
+
+@RunWith(BlockJUnit4ClassRunner.class)
+public class StringUtilsTest {
+
+ @Test
+ public void checkTabulatorReplacing() throws UnsupportedEncodingException {
+ assertEquals("asdfsaf asdfsafsafwer", StringUtils.convertStringToPDFFormat("asdfsaf\u0009asdfsafsafwer"));
+
+ }
+
+}