Don't throw UnsupportedOpEx on multi-char negative/percent symbols.

There seem to be a fair number of apps that call through to this
function, so just give them a "bogus" value (from Locale.ROOT) when
we encounter a multi-char symbol. The formatters and other java.text
APIs already use the correct multi-char value.

bug: 18785260
Change-Id: I80f2852fadbb590d598e4e38795e71fd12566c38
diff --git a/luni/src/main/java/java/text/DecimalFormatSymbols.java b/luni/src/main/java/java/text/DecimalFormatSymbols.java
index 69c4935..006d37b 100644
--- a/luni/src/main/java/java/text/DecimalFormatSymbols.java
+++ b/luni/src/main/java/java/text/DecimalFormatSymbols.java
@@ -297,8 +297,14 @@
             return minusSign.charAt(0);
         }
 
-        throw new UnsupportedOperationException(
-                "Minus sign spans multiple characters: " + minusSign);
+        // Return the minus sign from Locale.ROOT instead of crashing. None of libcore the parsers
+        // or formatters actually call this function, they use {@code getMinusSignString()} instead
+        // and that function always returns the correct (possibly multi-char) symbol.
+        //
+        // Callers of this method that format strings and expect them to be parseable by
+        // the "standard" parsers (or vice-versa) are hosed, but there's not much we can do to
+        // save them.
+        return '-';
     }
 
     /** @hide */
@@ -349,7 +355,15 @@
         if (percent.length() == 1) {
             return percent.charAt(0);
         }
-        throw new UnsupportedOperationException("Percent spans multiple characters: " + percent);
+
+        // Return the percent sign from Locale.ROOT instead of crashing. None of the libcore parsers
+        // or formatters actually call this function, they use {@code getPercentString()} instead
+        // and that function always returns the correct (possibly multi-char) symbol.
+        //
+        // Callers of this method that format strings and expect them to be parseable by
+        // the "standard" parsers (or vice-versa) are hosed, but there's not much we can do to
+        // save them.
+        return '%';
     }
 
     /**
diff --git a/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java b/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java
index 564001a..b1d37f3 100644
--- a/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java
+++ b/luni/src/test/java/libcore/java/text/DecimalFormatSymbolsTest.java
@@ -106,4 +106,14 @@
         assertEquals(dfs.getMinusSignString(), deserializedDfs.getMinusSignString());
         assertEquals(dfs.getPercentString(), deserializedDfs.getPercentString());
     }
+
+    // http://b/18785260
+    public void testMultiCharMinusSignAndPercentage() {
+        DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.forLanguageTag("ar-AR"));
+        assertTrue(dfs.getMinusSignString().length() > 1);
+        assertTrue(dfs.getPercentString().length() > 1);
+
+        assertEquals('%', dfs.getPercent());
+        assertEquals('-', dfs.getMinusSign());
+    }
 }