Creation of Collator for Chinese locals fails
Created by: pgammans
Creating a Collator and rebuilding from its rules fails for Chinese Collator's
The following code works if you change the locale to Locale("en", "US", "") , Locale("da", "DK", "") and a few others but not Locale("zh", "hant", "TW") , Locale("zh", "hans", "CN") , Locale("zh", "CN")
import icu
zh_TWCollator= icu.Collator.createInstance(icu.Locale("zh", "TW"))
zh_TWRules = zh_TWCollator.getRules();
newCollator = icu.RuleBasedCollator(zh_TWRules)
Traceback (most recent call last): File "", line 1, in ICUError: Character conversion: Unmappable input sequence. In other APIs: Invalid character., error code: 10
ie this line fails.
icu.Collator.createInstance(icu.Locale("zh", "TW"))
Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode character u'\u0101' in position 34: ordinal not in range(128)