summaryrefslogtreecommitdiff
path: root/javaunohelper
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-10-14 15:19:00 +0200
committerNoel Grandin <noel@peralex.com>2015-10-14 15:45:41 +0200
commit7974269a84ebf2f1264a0964155d23f9885b1808 (patch)
tree82a53ec7465e6f09f573629374cbb95a53f59080 /javaunohelper
parentad280b67f8fda8f832a6a83bc5665df448c6ad00 (diff)
cid#1326733 Dm: Dubious method used
there is no point in re-decoding a Java String object, it is already UTF-16 Change-Id: Iedc59d457422d32b306782f24cac9b6c2f6b04fe
Diffstat (limited to 'javaunohelper')
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java54
1 files changed, 25 insertions, 29 deletions
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java b/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java
index b0c31353971f..63ae35e7420c 100644
--- a/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java
+++ b/javaunohelper/com/sun/star/lib/uno/helper/UnoUrl.java
@@ -206,40 +206,36 @@ public class UnoUrl {
private static String decodeUTF8(String s)
throws com.sun.star.lang.IllegalArgumentException {
+ if (!s.contains("%")) {
+ return s;
+ }
try {
- if (s.contains("%")) {
- int length = s.length();
- ByteBuffer bb = ByteBuffer.allocate(length);
- for (int i = 0; i < length; i++) {
- int ch = s.charAt(i);
-
- if (ch == '%') {
- if (i+3 > length)
- throw new com.sun.star.lang.IllegalArgumentException(
- "Incomplete trailing escape (%) pattern");
- try {
- ch = Integer.parseInt(s.substring(i+1,i+3),16);
- } catch (NumberFormatException e) {
- throw new com.sun.star.lang.IllegalArgumentException(e);
- }
- if (ch < 0)
- throw new com.sun.star.lang.IllegalArgumentException(
- "Illegal hex characters in escape (%) pattern - negative value");
- i+=2;
+ int length = s.length();
+ ByteBuffer bb = ByteBuffer.allocate(length);
+ for (int i = 0; i < length; i++) {
+ int ch = s.charAt(i);
+
+ if (ch == '%') {
+ if (i+3 > length)
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Incomplete trailing escape (%) pattern");
+ try {
+ ch = Integer.parseInt(s.substring(i+1,i+3),16);
+ } catch (NumberFormatException e) {
+ throw new com.sun.star.lang.IllegalArgumentException(e);
}
-
- bb.put((byte) (ch & 0xFF));
+ if (ch < 0)
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Illegal hex characters in escape (%) pattern - negative value");
+ i+=2;
}
- byte[] bytes = new byte[bb.position()];
- System.arraycopy(bb.array(), 0, bytes, 0, bytes.length);
- return new String(bytes, "UTF-8");
-
- } else {
-
- return new String(s.getBytes(), "UTF-8");
-
+ bb.put((byte) (ch & 0xFF));
}
+
+ byte[] bytes = new byte[bb.position()];
+ System.arraycopy(bb.array(), 0, bytes, 0, bytes.length);
+ return new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new com.sun.star.lang.IllegalArgumentException(e,
"Couldn't convert parameter string to UTF-8 string");