1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 **********************************************************************
5 * Copyright (C) 2001-2009, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
8 * Date Name Description
9 * 05/23/00 aliu Creation.
10 **********************************************************************
13 #include "unicode/unistr.h"
16 static const UChar HEX[16]={48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70};
18 UnicodeString &TestUtility::appendHex(UnicodeString &buf, UChar32 ch) {
21 buf.append(HEX[0xF&(ch>>20)]);
23 buf.append(HEX[0xF&(ch>>16)]);
25 buf.append(HEX[0xF&(ch>>12)]);
26 buf.append(HEX[0xF&(ch>>8)]);
27 buf.append(HEX[0xF&(ch>>4)]);
28 buf.append(HEX[0xF&ch]);
32 UnicodeString TestUtility::hex(UChar32 ch) {
38 UnicodeString TestUtility::hex(const UnicodeString& s) {
39 return hex(s, 44 /*,*/);
42 UnicodeString TestUtility::hex(const UnicodeString& s, UChar sep) {
44 if (s.isEmpty()) return result;
46 for (int32_t i = 0; i < s.length(); i += U16_LENGTH(c)) {
56 UnicodeString TestUtility::hex(const uint8_t* bytes, int32_t len) {
58 for (int32_t i = 0; i < len; ++i) {
59 buf.append(HEX[0x0F & (bytes[i] >> 4)]);
60 buf.append(HEX[0x0F & bytes[i]]);