ICU-1681 support 1.0 and extended names

X-SVN-Rev: 8262
This commit is contained in:
Alan Liu 2002-03-27 19:12:05 +00:00
parent d243400c66
commit 6aa1dc81bf
3 changed files with 17 additions and 15 deletions

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/translit/TransliteratorTest.java,v $
* $Date: 2002/03/15 20:09:19 $
* $Revision: 1.100 $
* $Date: 2002/03/27 19:12:05 $
* $Revision: 1.101 $
*
*****************************************************************************************
*/
@ -817,10 +817,10 @@ public class TransliteratorTest extends TestFmwk {
Transliterator name2uni =
Transliterator.getInstance("Name-Any");
expect(uni2name, "\u00A0abc\u4E01\u00B5\u0A81\uFFFD\uFFFF",
"{NO-BREAK SPACE}abc{CJK UNIFIED IDEOGRAPH-4E01}{MICRO SIGN}{GUJARATI SIGN CANDRABINDU}{REPLACEMENT CHARACTER}\uFFFF");
expect(name2uni, "{ NO-BREAK SPACE}abc{ CJK UNIFIED IDEOGRAPH-4E01 }{x{MICRO SIGN}{GUJARATI SIGN CANDRABINDU}{REPLACEMENT CHARACTER}{",
"\u00A0abc\u4E01{x\u00B5\u0A81\uFFFD{");
expect(uni2name, "\u00A0abc\u4E01\u00B5\u0A81\uFFFD\u0004\u0009\u0081\uFFFF",
"{NO-BREAK SPACE}abc{CJK UNIFIED IDEOGRAPH-4E01}{MICRO SIGN}{GUJARATI SIGN CANDRABINDU}{REPLACEMENT CHARACTER}{END OF TRANSMISSION}{HORIZONTAL TABULATION}{<control-0081>}{<noncharacter-FFFF>}");
expect(name2uni, "{ NO-BREAK SPACE}abc{ CJK UNIFIED IDEOGRAPH-4E01 }{x{MICRO SIGN}{GUJARATI SIGN CANDRABINDU}{REPLACEMENT CHARACTER}{END OF TRANSMISSION}{HORIZONTAL TABULATION}{<control-0081>}{<noncharacter-FFFF>}{<control-0004>}{",
"\u00A0abc\u4E01{x\u00B5\u0A81\uFFFD\u0004\u0009\u0081\uFFFF\u0004{");
}
/**

View File

@ -3,8 +3,8 @@
* others. All Rights Reserved.
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/NameUnicodeTransliterator.java,v $
* $Date: 2002/02/16 03:06:10 $
* $Revision: 1.8 $
* $Date: 2002/03/27 19:11:37 $
* $Revision: 1.9 $
*/
package com.ibm.icu.text;
import java.util.*;
@ -89,7 +89,7 @@ class NameUnicodeTransliterator extends Transliterator {
break;
case 1: // after open delimiter
// Look for [-a-zA-Z0-9]. If \w+ is found, convert it
// Look for [-a-zA-Z0-9]. If \s+ is found, convert it
// to a single space. If closeDelimiter is found, exit
// the loop. If any other character is found, exit the
// loop. If the limit is found, exit the loop.
@ -110,7 +110,7 @@ class NameUnicodeTransliterator extends Transliterator {
if (ibuf > 0 && buf[ibuf-1] == (char)0x0020) {
--ibuf;
}
int ch = UCharacter.getCharFromName(new String(buf, 0, ibuf));
int ch = UCharacter.getCharFromExtendedName(new String(buf, 0, ibuf));
if (ch != -1) {
// Lookup succeeded
String str = UTF16.valueOf(ch);
@ -134,10 +134,12 @@ class NameUnicodeTransliterator extends Transliterator {
c -= 0x0020; // [a-z] => [A-Z]
}
// Check if c =~ [-A-Z0-9]
// Check if c =~ [-A-Za-z0-9<>]
if (c == (char)0x002D ||
(c >= (char)0x0041 && c <= (char)0x005A) ||
(c >= (char)0x0030 && c <= (char)0x0039)) {
(c >= (char)0x0061 && c <= (char)0x007A) ||
(c >= (char)0x0030 && c <= (char)0x0039) ||
c == (char)0x003C || c == (char)0x003E) {
buf[ibuf++] = (char) c;
// If we go a bit past the longest possible name then abort
if (ibuf == (LONGEST_NAME + 4)) {

View File

@ -3,8 +3,8 @@
* others. All Rights Reserved.
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/UnicodeNameTransliterator.java,v $
* $Date: 2002/02/16 03:06:22 $
* $Revision: 1.7 $
* $Date: 2002/03/27 19:11:37 $
* $Revision: 1.8 $
*/
package com.ibm.icu.text;
import java.util.*;
@ -65,7 +65,7 @@ class UnicodeNameTransliterator extends Transliterator {
while (cursor < limit) {
int c = text.char32At(cursor);
if ((name=UCharacter.getName(c)) != null) {
if ((name=UCharacter.getExtendedName(c)) != null) {
str.setLength(1);
str.append(name).append(closeDelimiter);