]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/testutil.cpp
2 **********************************************************************
3 * Copyright (C) 2001-2009, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 * Date Name Description
7 * 05/23/00 aliu Creation.
8 **********************************************************************
11 #include "unicode/unistr.h"
14 static const UChar HEX
[16]={48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70};
16 UnicodeString
&TestUtility::appendHex(UnicodeString
&buf
, UChar32 ch
) {
19 buf
.append(HEX
[0xF&(ch
>>20)]);
21 buf
.append(HEX
[0xF&(ch
>>16)]);
23 buf
.append(HEX
[0xF&(ch
>>12)]);
24 buf
.append(HEX
[0xF&(ch
>>8)]);
25 buf
.append(HEX
[0xF&(ch
>>4)]);
26 buf
.append(HEX
[0xF&ch
]);
30 UnicodeString
TestUtility::hex(UChar32 ch
) {
36 UnicodeString
TestUtility::hex(const UnicodeString
& s
) {
37 return hex(s
, 44 /*,*/);
40 UnicodeString
TestUtility::hex(const UnicodeString
& s
, UChar sep
) {
42 if (s
.isEmpty()) return result
;
44 for (int32_t i
= 0; i
< s
.length(); i
+= U16_LENGTH(c
)) {
54 UnicodeString
TestUtility::hex(const uint8_t* bytes
, int32_t len
) {
56 for (int32_t i
= 0; i
< len
; ++i
) {
57 buf
.append(HEX
[0x0F & (bytes
[i
] >> 4)]);
58 buf
.append(HEX
[0x0F & bytes
[i
]]);