ICU-45 Added an overloaded function prettify(UnicodeString&)

X-SVN-Rev: 594
This commit is contained in:
Madhu K 2000-01-15 01:55:02 +00:00
parent 7b897b7cbf
commit af280174c1
2 changed files with 29 additions and 0 deletions

View File

@ -319,7 +319,35 @@ IntlTest::prettify(const UnicodeString &source,
return target;
}
// Replace nonprintable characters with unicode escapes
UnicodeString
IntlTest::prettify(const UnicodeString &source)
{
int32_t i;
UnicodeString target;
target.remove();
target += "\"";
for (i = 0; i < source.length(); i += 1)
{
UChar ch = source[i];
if (ch < 0x09 || (ch > 0x0A && ch < 0x20)|| ch > 0x7E)
{
target += "\\u";
appendHex(ch, 4, target);
}
else
{
target += ch;
}
}
target += "\"";
return target;
}
// Produce a printable representation of a CollationKey
UnicodeString &IntlTest::prettify(const CollationKey &source, UnicodeString &target)
{

View File

@ -127,6 +127,7 @@ protected:
Collator::EComparisonResult expectedResult );
static UnicodeString &prettify(const UnicodeString &source, UnicodeString &target);
static UnicodeString prettify(const UnicodeString &source);
static UnicodeString &prettify(const CollationKey &source, UnicodeString &target);
static UnicodeString &appendHex(uint32_t number, int8_t digits, UnicodeString &target);
static UnicodeString &appendCompareResult(Collator::EComparisonResult result, UnicodeString &target);