fix unicodeTrim on all-whitespace strings

This commit is contained in:
Havoc Pennington 2011-11-15 23:26:43 -05:00
parent 41b9d5c68b
commit e9fe426f7f
2 changed files with 3 additions and 2 deletions

View File

@ -79,7 +79,7 @@ final public class ConfigUtil {
return s;
int start = 0;
while (true) {
while (start < length) {
char c = s.charAt(start);
if (c == ' ' || c == '\n') {
start += 1;
@ -93,7 +93,7 @@ final public class ConfigUtil {
}
int end = length;
while (true) {
while (end > start) {
char c = s.charAt(end - 1);
if (c == ' ' || c == '\n') {
--end;

View File

@ -21,6 +21,7 @@ class UtilTest extends TestUtils {
assertEquals("", ConfigUtil.unicodeTrim(""))
assertEquals("a", ConfigUtil.unicodeTrim("a"))
assertEquals("abc", ConfigUtil.unicodeTrim("abc"))
assertEquals("", ConfigUtil.unicodeTrim(" \n \n \u00A0 "))
assertEquals(supplementaryChars, ConfigUtil.unicodeTrim(supplementaryChars))
val s = " \u00A0 \n " + supplementaryChars + " \n \u00A0 "