ICU-8795 Remove suffix when CharsetMatch is creating a new string
X-SVN-Rev: 30648
This commit is contained in:
parent
8981a441b2
commit
844d3c5e1f
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
* Copyright (C) 2005-2010, International Business Machines Corporation and *
|
* Copyright (C) 2005-2011, International Business Machines Corporation and *
|
||||||
* others. All Rights Reserved. *
|
* others. All Rights Reserved. *
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
*/
|
*/
|
||||||
@ -102,7 +102,17 @@ public class CharsetMatch implements Comparable<CharsetMatch> {
|
|||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
} else {
|
} else {
|
||||||
result = new String(fRawInput, getName());
|
String name = getName();
|
||||||
|
/*
|
||||||
|
* getName() may return a name with a suffix 'rtl' or 'ltr'. This cannot
|
||||||
|
* be used to open a charset (e.g. IBM424_rtl). The ending '_rtl' or 'ltr'
|
||||||
|
* should be stripped off before creating the string.
|
||||||
|
*/
|
||||||
|
int startSuffix = name.indexOf("_rtl") < 0 ? name.indexOf("_ltr") : name.indexOf("_rtl");
|
||||||
|
if (startSuffix > 0) {
|
||||||
|
name = name.substring(0, startSuffix);
|
||||||
|
}
|
||||||
|
result = new String(fRawInput, name);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -617,11 +617,21 @@ public class TestCharsetDetector extends TestFmwk
|
|||||||
charsetMatch = m.getName();
|
charsetMatch = m.getName();
|
||||||
CheckAssert(charsetMatch.equals("IBM424_rtl"));
|
CheckAssert(charsetMatch.equals("IBM424_rtl"));
|
||||||
CheckAssert(m.getLanguage().equals("he"));
|
CheckAssert(m.getLanguage().equals("he"));
|
||||||
|
try {
|
||||||
|
m.getString();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
errln("Error getting string for charsetMatch: " + charsetMatch);
|
||||||
|
}
|
||||||
|
|
||||||
m = _testIBM424_he_ltr(s);
|
m = _testIBM424_he_ltr(s);
|
||||||
charsetMatch = m.getName();
|
charsetMatch = m.getName();
|
||||||
CheckAssert(charsetMatch.equals("IBM424_ltr"));
|
CheckAssert(charsetMatch.equals("IBM424_ltr"));
|
||||||
CheckAssert(m.getLanguage().equals("he"));
|
CheckAssert(m.getLanguage().equals("he"));
|
||||||
|
try {
|
||||||
|
m.getString();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
errln("Error getting string for charsetMatch: " + charsetMatch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CharsetMatch _test1255(String s) throws Exception {
|
private CharsetMatch _test1255(String s) throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user