45 #define UTF16_HEADER_VALUE 0x11 // Unicode header value 46 #define UCS2_HEADER_VALUE 0x14 // UCS-2BE header value 47 #define UTF8_HEADER_VALUE 0x15 // UTF-8 header value 48 #define UNICODE_HEADER_POS 0 // Unicode header, start position in string 49 #define LENGTH_LOOP_LIMIT INVALID_UNICODE_CHAR // Catch for non null terminated strings 52 #define STRINGS_EQUAL 0 // Return value when compared strings are the same 53 #define FIRST_STRING_GREATER 1 // Return value when 1st string is greater than 2nd 54 #define SECOND_STRING_GREATER -1 // Return value when 2nd string is greater than 1st 56 #define MAX_NUMBER_DIGITS 11 // Maximum number digits in a S32BIT number (e.g. -2147483648 ) 60 #define UNI_PERCENT_CHAR 0x0025 61 #define UNI_SMALL_D_CHAR 0x0064 62 #define UNI_SMALL_H_CHAR 0x0068 63 #define UNI_SMALL_U_CHAR 0x0075 64 #define UNI_SMALL_L_CHAR 0x006C 65 #define UNI_SMALL_S_CHAR 0x0073 66 #define UNI_SMALL_X_CHAR 0x0078 67 #define UNI_LARGE_X_CHAR 0x0058 68 #define UNI_ZERO_CHAR 0x0030 69 #define UNI_NINE_CHAR 0x0039 71 #define UNI_SUR_HIGH_START 0xD800 72 #define UNI_SUR_HIGH_END 0xDBFF 73 #define UNI_SUR_LOW_START 0xDC00 74 #define UNI_SUR_LOW_END 0xDFFF 75 #define UNI_REPLACEMENT_CHAR 0x0000FFFD 78 #define UNI_SMALL_L_SMALL_D_CHARS ((UNI_SMALL_L_CHAR << 16) | UNI_SMALL_D_CHAR) 79 #define UNI_SMALL_L_SMALL_U_CHARS ((UNI_SMALL_L_CHAR << 16) | UNI_SMALL_U_CHAR) 80 #define UNI_SMALL_L_SMALL_X_CHARS ((UNI_SMALL_L_CHAR << 16) | UNI_SMALL_X_CHAR) 81 #define UNI_SMALL_L_LARGE_X_CHARS ((UNI_SMALL_L_CHAR << 16) | UNI_LARGE_X_CHAR) 82 #define UNI_SMALL_H_SMALL_D_CHARS ((UNI_SMALL_H_CHAR << 16) | UNI_SMALL_D_CHAR) 83 #define UNI_SMALL_H_SMALL_U_CHARS ((UNI_SMALL_H_CHAR << 16) | UNI_SMALL_U_CHAR) 84 #define UNI_SMALL_H_SMALL_X_CHARS ((UNI_SMALL_H_CHAR << 16) | UNI_SMALL_X_CHAR) 85 #define UNI_SMALL_H_LARGE_X_CHARS ((UNI_SMALL_H_CHAR << 16) | UNI_LARGE_X_CHAR) 87 #define MAX_DECODE_BUFFER_SIZE 255 88 #define MAX_NUM_FORMAT_SPEC_STR_SIZE 6 89 #define MAX_NUM_WIDTH_DIGITS 3 109 {(U32BIT)((
'r' << 16) | (
'u' << 8) |
'm'), 2},
110 {(U32BIT)((
'r' << 16) | (
'o' << 8) |
'n'), 2}
114 static U8BIT default_ascii_table = 0;
119 static BOOLEAN CheckUnicodeCharForReverseDirection(U16BIT unicode);
120 static void MakeUnicode( U8BIT **addr_string_ptr, BOOLEAN *new_string,
121 U16BIT *length_ptr, BOOLEAN *reverse_dir, BOOLEAN strip_DVB_cntrl_char);
122 static U8BIT* OutputUTF8(U8BIT *buffer, U32BIT char_code);
123 static U32BIT ReadUTF8(U8BIT **buffer);
124 static U32BIT CharToLower(U32BIT char_code);
143 U32BIT string_length;
144 U32BIT string_offset;
150 ASSERT(string_ptr != NULL);
156 if (string_ptr != NULL)
158 if ((string_ptr[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE) || (string_ptr[UNICODE_HEADER_POS] == UCS2_HEADER_VALUE))
167 if (string_ptr[string_offset] ==
'\0' && string_ptr[string_offset + 1] ==
'\0')
175 while (string_length < LENGTH_LOOP_LIMIT);
177 else if (string_ptr[UNICODE_HEADER_POS] == UTF8_HEADER_VALUE)
179 ptr = string_ptr + 1;
181 while ((char_code = ReadUTF8(&ptr)) != 0)
190 return(string_length);
215 if ((string_ptr != NULL) && (string_ptr[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE))
222 while ((offset_count < num_bytes) && (is_reversed == FALSE))
225 unicode = ((*(string_ptr + offset_count)) << 8) | ((*(string_ptr + offset_count + 1)));
227 is_reversed = CheckUnicodeCharForReverseDirection(unicode );
254 if ((string_ptr != NULL) &&
255 ((string_ptr[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE) ||
256 (string_ptr[UNICODE_HEADER_POS] == UTF8_HEADER_VALUE)))
288 if (string_ptr != NULL)
290 if ((*string_ptr == 0) || (*string_ptr >= 0x20))
317 BOOLEAN prev_char_null;
323 if (string_ptr != NULL)
325 byte_val = string_ptr[0];
326 if (byte_val >= 0x20)
329 num_bytes = strlen((
char *)string_ptr) + 1;
331 else if (byte_val == 0)
336 else if ((byte_val >= 1) && (byte_val <= 11))
339 num_bytes = strlen((
char *)(string_ptr + 1)) + 2;
341 else if (byte_val == 0x10)
344 num_bytes = strlen((
char *)(string_ptr + 3)) + 4;
346 else if ((byte_val == UTF16_HEADER_VALUE) || (byte_val == UCS2_HEADER_VALUE))
350 if (num_chars != INVALID_UNICODE_CHAR)
352 num_bytes = STB_UTF16_LEN_TO_BYTES_IN_STRING(num_chars);
355 else if (byte_val == UTF8_HEADER_VALUE)
358 num_bytes = strlen((
char *)(string_ptr + 1)) + 2;
360 else if (byte_val == 0x1f)
367 prev_char_null = FALSE;
369 for (num_bytes = 0; !finished; )
371 if (string_ptr[num_bytes] == 0)
380 prev_char_null = TRUE;
386 prev_char_null = FALSE;
414 U32BIT string_length;
419 ASSERT(string_ptr != NULL);
420 ASSERT((string_ptr[0] == UTF16_HEADER_VALUE) || (string_ptr[0] == UTF8_HEADER_VALUE));
423 if (string_ptr != NULL && string_ptr[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE)
428 if (char_id >= string_length)
431 string_ptr =
STB_ResizeMemory(string_ptr, STB_UTF16_LEN_TO_BYTES_IN_STRING(string_length));
434 char_id = (U16BIT) string_length;
438 if (string_ptr != NULL)
441 byte_offset = (char_id * 2) + 1;
443 string_ptr[byte_offset] = (U8BIT) (code >> 8);
446 string_ptr[byte_offset] = (U8BIT) (code & 0x00FF);
450 if (char_id == string_length)
452 string_ptr[byte_offset++] =
'\0';
455 string_ptr[byte_offset] =
'\0';
479 U32BIT string_length;
484 ASSERT(string_ptr != NULL);
485 ASSERT((string_ptr[0] == UTF16_HEADER_VALUE) || (string_ptr[0] == UTF8_HEADER_VALUE));
488 if (string_ptr != NULL && string_ptr[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE)
493 if (char_id < string_length)
496 byte_offset = (char_id * 2) + 1;
499 memcpy(&string_ptr[byte_offset], &string_ptr[byte_offset + 2],
500 ((string_length - char_id) * 2));
528 U32BIT string_length;
534 ASSERT(string_ptr != NULL);
535 ASSERT((string_ptr[0] == UTF16_HEADER_VALUE) || (string_ptr[0] == UTF8_HEADER_VALUE));
537 return_code = INVALID_UNICODE_CHAR;
540 if (string_ptr != NULL)
542 if (string_ptr[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE)
546 if (char_id <= string_length)
549 byte_offset = (char_id * 2) + 1;
551 return_code = (U16BIT) (string_ptr[byte_offset] << 8);
554 return_code |= (U16BIT) string_ptr[byte_offset];
557 else if (string_ptr[UNICODE_HEADER_POS] == UTF8_HEADER_VALUE)
563 if ((*string_ptr & 0x80) == 0)
568 else if ((*string_ptr & 0xE0) == 0xC0)
573 else if ((*string_ptr & 0xF0) == 0xE0)
578 else if ((*string_ptr & 0xF8) == 0xF0)
591 if (string_ptr != NULL)
593 return_code = ReadUTF8(&string_ptr);
623 U8BIT *concatinated_string_ptr;
624 U32BIT new_string_byte_count;
630 ASSERT(string1_ptr != NULL);
631 ASSERT(string2_ptr != NULL);
633 concatinated_string_ptr = NULL;
636 if ((string1_ptr != NULL) && (string2_ptr != NULL))
641 if (((string1_ptr[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE) &&
642 (string2_ptr[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE)) ||
643 ((string1_ptr[UNICODE_HEADER_POS] == UTF8_HEADER_VALUE) &&
644 (string2_ptr[UNICODE_HEADER_POS] == UTF8_HEADER_VALUE)))
654 string1_ptr = unicode_str1;
658 string2_ptr = unicode_str2;
662 if ((string1_ptr != NULL) && (string2_ptr != NULL))
664 if (string1_ptr[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE)
668 new_string_byte_count = num_bytes1 + num_bytes2 - 3;
674 new_string_byte_count = num_bytes1 + num_bytes2 - 2;
677 concatinated_string_ptr = (U8BIT *)
STB_GetMemory(new_string_byte_count);
678 if (concatinated_string_ptr != NULL)
680 if (string1_ptr[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE)
684 memcpy(&concatinated_string_ptr[0], string1_ptr, num_bytes1 - 2);
687 memcpy((
char *)&concatinated_string_ptr[num_bytes1 - 2], &string2_ptr[1], num_bytes2 - 1);
693 memcpy(&concatinated_string_ptr[0], string1_ptr, num_bytes1 - 1);
696 memcpy((
char *)&concatinated_string_ptr[num_bytes1 - 1], &string2_ptr[1], num_bytes2 - 1);
707 return(concatinated_string_ptr);
725 U8BIT *return_ptr = NULL;
726 U8BIT *next_char_ptr;
731 ASSERT(save_ptr != NULL);
735 if ((
string == NULL) && (*save_ptr != NULL))
739 *
string = UTF8_HEADER_VALUE;
742 if ((
string != NULL) && (
string[UNICODE_HEADER_POS] == UTF8_HEADER_VALUE))
745 next_char_ptr =
string + 1;
748 while ((char_code = ReadUTF8(&next_char_ptr)) != 0)
750 if (char_code == 0x20)
756 while ((char_code = ReadUTF8(&next_char_ptr)) == 0x20)
758 string = next_char_ptr;
765 string = next_char_ptr;
790 U8BIT *subs_ptr = NULL;
794 U32BIT str1_cmp_index;
795 U32BIT str2_cmp_index;
797 U8BIT *next_str1_ptr;
800 U32BIT str1_char, str2_char;
805 if ((str1 != NULL) && (str2 != NULL))
807 if ((str1[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE) &&
808 (str2[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE))
816 while (str1_index < str1_len)
818 str1_cmp_index = str1_index;
821 while ((str1_cmp_index < str1_len) && (str2_cmp_index < str2_len))
828 str1_char = CharToLower(str1_char);
829 str2_char = CharToLower(str2_char);
832 if (str1_char != str2_char)
841 if (str2_cmp_index >= str2_len)
843 subs_ptr = &str1[1 + ((str1_cmp_index - 1) * 2)];
849 else if ((str1[UNICODE_HEADER_POS] == UTF8_HEADER_VALUE) &&
850 (str2[UNICODE_HEADER_POS] == UTF8_HEADER_VALUE))
854 next_str1_ptr = str1_ptr;
855 str1_char = ReadUTF8(&next_str1_ptr);
857 while (str1_char != 0)
859 str1_cmp_ptr = str1_ptr;
860 str2_cmp_ptr = &str2[1];
864 str1_char = ReadUTF8(&str1_cmp_ptr);
865 str2_char = ReadUTF8(&str2_cmp_ptr);
869 str1_char = CharToLower(str1_char);
870 str2_char = CharToLower(str2_char);
873 while ((str1_char != 0) && (str2_char != 0) && (str1_char == str2_char));
882 str1_ptr = next_str1_ptr;
883 str1_char = ReadUTF8(&next_str1_ptr);
912 U32BIT string1_length;
913 U32BIT string2_length;
914 U32BIT min_string_length;
915 U32BIT unicode_count;
917 U32BIT current_string1_code;
918 U32BIT current_string2_code;
919 S8BIT difference = STRINGS_EQUAL;
925 ASSERT(string1_ptr != NULL);
926 ASSERT(string2_ptr != NULL);
929 if ((string1_ptr != NULL) && (string2_ptr != NULL))
931 if ((string1_ptr[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE) &&
932 (string2_ptr[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE))
938 if (string1_length < string2_length)
940 min_string_length = string1_length;
944 min_string_length = string2_length;
947 difference = STRINGS_EQUAL;
952 while (unicode_count <= min_string_length && difference == STRINGS_EQUAL)
954 current_string1_code = (U16BIT) (string1_ptr[byte_offset] << 8);
955 current_string2_code = (U16BIT) (string2_ptr[byte_offset] << 8);
957 current_string1_code |= (U16BIT) string1_ptr[byte_offset];
958 current_string2_code |= (U16BIT) string2_ptr[byte_offset];
963 current_string1_code = CharToLower(current_string1_code);
964 current_string2_code = CharToLower(current_string2_code);
967 if (current_string1_code > current_string2_code)
969 difference = FIRST_STRING_GREATER;
971 else if (current_string1_code < current_string2_code)
973 difference = SECOND_STRING_GREATER;
979 else if ((string1_ptr[UNICODE_HEADER_POS] == UTF8_HEADER_VALUE) &&
980 (string2_ptr[UNICODE_HEADER_POS] == UTF8_HEADER_VALUE))
982 ptr1 = &string1_ptr[1];
983 ptr2 = &string2_ptr[1];
984 current_string1_code = ReadUTF8(&ptr1);
985 current_string2_code = ReadUTF8(&ptr2);
989 current_string1_code = CharToLower(current_string1_code);
990 current_string2_code = CharToLower(current_string2_code);
993 while ((current_string1_code != 0) && (current_string2_code != 0) &&
994 (difference == STRINGS_EQUAL))
996 if (current_string1_code > current_string2_code)
998 difference = FIRST_STRING_GREATER;
1000 else if (current_string1_code < current_string2_code)
1002 difference = SECOND_STRING_GREATER;
1006 current_string1_code = ReadUTF8(&ptr1);
1007 current_string2_code = ReadUTF8(&ptr2);
1011 current_string1_code = CharToLower(current_string1_code);
1012 current_string2_code = CharToLower(current_string2_code);
1017 if (exact_match && (difference == STRINGS_EQUAL))
1027 difference = strcmp((
char *) string1_ptr, (
char *) string2_ptr);
1028 exact_match = FALSE;
1033 if (exact_match == TRUE)
1035 if ((difference == STRINGS_EQUAL) && (string1_length != string2_length))
1037 if (string1_length < string2_length)
1039 difference = SECOND_STRING_GREATER;
1043 difference = FIRST_STRING_GREATER;
1070 BOOLEAN strip_DVB_cntrl_char, U32BIT lang_code)
1074 BOOLEAN convert_reqd;
1082 U8BIT *decoded_utf8;
1088 U8BIT encoding_type_id;
1093 ASSERT(reverse_dir != NULL);
1094 ASSERT(nchar != NULL);
1103 decoded_utf8 = NULL;
1108 table_id = default_ascii_table;
1113 for (i = 0; i < (
sizeof(lang_code_lookup_table) /
sizeof(
S_LANG_CODE_ENTRY)); i++)
1115 if (lang_code_lookup_table[i].lang_code == lang_code)
1117 table_id = lang_code_lookup_table[i].table_id;
1125 byte_val = *char_ptr;
1126 if ((byte_val >= 0x20) || (byte_val ==
'\0'))
1129 convert_reqd = TRUE;
1131 num_ip_char = (U16BIT) strlen((
char *)char_ptr);
1133 else if ((byte_val >= 1) && (byte_val <= 11))
1138 convert_reqd = TRUE;
1139 table = byte_val + 4;
1141 num_ip_char = (U16BIT) strlen((
char *)char_ptr);
1143 else if (byte_val == 0x10)
1146 convert_reqd = TRUE;
1147 table = ((*(char_ptr + 1)) << 8) | *(char_ptr + 2);
1149 num_ip_char = (U16BIT) strlen((
char *)char_ptr);
1151 else if (byte_val == 0x11)
1154 convert_reqd = FALSE;
1161 unicode = ((*char_ptr) << 8) | *(char_ptr + 1);
1163 if (unicode !=
'\0')
1168 while (unicode !=
'\0');
1169 char_ptr =
string + 1;
1171 else if ((byte_val == UTF8_HEADER_VALUE) || (byte_val == 0x1F))
1173 if (byte_val == UTF8_HEADER_VALUE)
1183 encoding_type_id = *char_ptr;
1186 if ((encoding_type_id == 1) || (encoding_type_id == 2))
1190 decoded_utf8 = (U8BIT *)
STB_GetMemory(MAX_DECODE_BUFFER_SIZE);
1191 if (decoded_utf8 != NULL)
1194 MAX_DECODE_BUFFER_SIZE);
1196 if (actual_size > 0)
1200 char_ptr = decoded_utf8;
1206 *reverse_dir = FALSE;
1216 *reverse_dir = FALSE;
1225 *reverse_dir = FALSE;
1232 convert_reqd = TRUE;
1241 if ((*char_ptr & 0x80) == 0)
1245 else if ((*char_ptr & 0xE0) == 0xC0)
1249 else if ((*char_ptr & 0xF0) == 0xE0)
1256 if (decoded_utf8 != NULL)
1262 *reverse_dir = FALSE;
1268 while (*char_ptr !=
'\0');
1270 if (decoded_utf8 != NULL)
1272 char_ptr = decoded_utf8;
1276 char_ptr =
string + 1;
1283 *reverse_dir = FALSE;
1290 nbytes = STB_UTF16_LEN_TO_BYTES_IN_STRING(num_ip_char);
1292 if (op_buff != NULL)
1302 for (i = 0; i < num_ip_char; i++)
1305 if (convert_reqd == FALSE)
1308 unicode = ((*char_ptr) << 8) | *(char_ptr + 1);
1315 byte_val = *char_ptr;
1316 if ((byte_val & 0x80) == 0)
1321 else if ((byte_val & 0xE0) == 0xC0)
1323 unicode = byte_val & 0x1F;
1325 unicode += (*(char_ptr + 1) & 0x3F);
1328 else if ((byte_val & 0xF0) == 0xE0)
1330 unicode = byte_val & 0x0F;
1332 unicode += (*(char_ptr + 1) & 0x3F);
1334 unicode += (*(char_ptr + 2) & 0x3F);
1337 if ((unicode >= CHAR_TABLE_START_ASCII_CODE) && (unicode <= 0xff))
1340 unicode = utf8_char_map[unicode - CHAR_TABLE_START_ASCII_CODE];
1346 byte_val = *char_ptr;
1348 if (byte_val < CHAR_TABLE_START_ASCII_CODE)
1350 unicode = (U16BIT)byte_val;
1354 if (table < MAX_CHAR_MAP_TABLES)
1356 unicode = char_map[table][byte_val - CHAR_TABLE_START_ASCII_CODE];
1363 if (((unicode > 0x0000) && (unicode <= 0x001f)) ||
1364 ((unicode >= 0x0080) && (unicode <= 0x009f)) ||
1365 ((unicode >= 0xe080) && (unicode <= 0xe09f))
1375 if (strip_DVB_cntrl_char == FALSE)
1389 if (strip_DVB_cntrl_char == FALSE)
1403 if (strip_DVB_cntrl_char == FALSE)
1432 if ((unicode < 0x300) || (unicode > 0x36f))
1436 *op_ptr = (U8BIT)((unicode >> 8) & 0xff);
1438 *op_ptr = (U8BIT)(unicode & 0xff);
1442 unicode = prev_char;
1448 if ((unicode >= 0x300) && (unicode <= 0x36f))
1451 prev_char = unicode;
1455 *op_ptr = (U8BIT)((unicode >> 8) & 0xff);
1457 *op_ptr = (U8BIT)(unicode & 0xff);
1463 if (reverse == FALSE)
1465 reverse = CheckUnicodeCharForReverseDirection(unicode);
1473 *(op_ptr + 1) = 0x00;
1476 if (decoded_utf8 != NULL)
1487 *nchar = num_op_char;
1488 *reverse_dir = reverse;
1520 U8BIT *decoded_utf8;
1527 U8BIT encoding_type_id;
1532 ASSERT(nchar != NULL);
1541 decoded_utf8 = NULL;
1546 table_id = default_ascii_table;
1551 for (i = 0; i < (
sizeof(lang_code_lookup_table) /
sizeof(
S_LANG_CODE_ENTRY)); i++)
1553 if (lang_code_lookup_table[i].lang_code == lang_code)
1555 table_id = lang_code_lookup_table[i].table_id;
1563 byte_val = *char_ptr;
1564 if ((byte_val >= 0x20) || (byte_val ==
'\0'))
1568 num_ip_char = (U16BIT)strlen((
char *)char_ptr);
1570 else if ((byte_val >= 1) && (byte_val <= 11))
1575 table = byte_val + 4;
1577 num_ip_char = (U16BIT)strlen((
char *)char_ptr);
1579 else if (byte_val == 0x10)
1582 table = ((*(char_ptr + 1)) << 8) | *(char_ptr + 2);
1584 num_ip_char = (U16BIT)strlen((
char *)char_ptr);
1586 else if ((byte_val == 0x11) || (byte_val == UCS2_HEADER_VALUE))
1595 unicode = ((*char_ptr) << 8) | *(char_ptr + 1);
1597 if (unicode !=
'\0')
1602 while (unicode !=
'\0');
1603 char_ptr =
string + 1;
1605 else if ((byte_val == UTF8_HEADER_VALUE) || (byte_val == 0x1F))
1611 if (byte_val == 0x1F)
1615 encoding_type_id = *char_ptr;
1618 if ((encoding_type_id == 1) || (encoding_type_id == 2))
1622 decoded_utf8 = (U8BIT *)
STB_GetMemory(MAX_DECODE_BUFFER_SIZE);
1623 if (decoded_utf8 != NULL)
1626 MAX_DECODE_BUFFER_SIZE);
1628 if (actual_size > 0)
1632 char_ptr = decoded_utf8;
1664 if ((*char_ptr & 0x80) == 0)
1668 else if ((*char_ptr & 0xE0) == 0xC0)
1672 else if ((*char_ptr & 0xF0) == 0xE0)
1676 else if ((*char_ptr & 0xF8) == 0xF0)
1683 if (decoded_utf8 != NULL)
1694 while (*char_ptr !=
'\0');
1696 if (decoded_utf8 != NULL)
1698 char_ptr = decoded_utf8;
1702 char_ptr =
string + 1;
1716 nbytes = num_ip_char * 4;
1723 if (op_buff != NULL)
1729 *op_ptr = UTF8_HEADER_VALUE;
1733 for (i = 0; i < num_ip_char; i++)
1738 unicode = ((*char_ptr) << 8) | *(char_ptr + 1);
1743 byte_val = *char_ptr;
1744 if ((byte_val & 0x80) == 0)
1749 else if ((byte_val & 0xE0) == 0xC0)
1751 unicode = byte_val & 0x1F;
1753 unicode += (*(char_ptr + 1) & 0x3F);
1756 else if ((byte_val & 0xF0) == 0xE0)
1758 unicode = byte_val & 0x0F;
1760 unicode += (*(char_ptr + 1) & 0x3F);
1762 unicode += (*(char_ptr + 2) & 0x3F);
1765 else if ((byte_val & 0xF8) == 0xF0)
1767 unicode = byte_val & 0x07;
1769 unicode += (*(char_ptr + 1) & 0x3F);
1771 unicode += (*(char_ptr + 2) & 0x3F);
1773 unicode += (*(char_ptr + 3) & 0x3F);
1777 if ((unicode >= CHAR_TABLE_START_ASCII_CODE) && (unicode <= 0xff))
1780 unicode = utf8_char_map[unicode - CHAR_TABLE_START_ASCII_CODE];
1786 byte_val = *char_ptr;
1788 if (byte_val < CHAR_TABLE_START_ASCII_CODE)
1790 unicode = (U32BIT)byte_val;
1794 if (table < MAX_CHAR_MAP_TABLES)
1796 unicode = char_map[table][byte_val - CHAR_TABLE_START_ASCII_CODE];
1802 if (((unicode > 0x0000) && (unicode <= 0x001f)) ||
1803 ((unicode >= 0x0080) && (unicode <= 0x009f)) ||
1804 ((unicode >= 0xe080) && (unicode <= 0xe09f)))
1813 if (strip_DVB_cntrl_char == FALSE)
1827 if (strip_DVB_cntrl_char == FALSE)
1841 if (strip_DVB_cntrl_char == FALSE)
1869 if ((unicode >= 0x300) && (unicode <= 0x36f))
1874 temp_char = unicode;
1875 unicode = prev_char;
1876 prev_char = temp_char;
1881 op_ptr = OutputUTF8(op_ptr, unicode);
1885 unicode = prev_char;
1891 if ((unicode >= 0x300) && (unicode <= 0x36f))
1894 prev_char = unicode;
1901 op_ptr = OutputUTF8(op_ptr, unicode);
1910 op_ptr = OutputUTF8(op_ptr, prev_char);
1917 if ((op_ptr - op_buff) < nbytes)
1919 nbytes = op_ptr - op_buff;
1924 if (decoded_utf8 != NULL)
1935 *nchar = num_op_char;
1976 const U32BIT byteMask = 0xBF;
1977 const U32BIT byteMark = 0x80;
1978 const int halfShift = 10;
1979 const U32BIT halfBase = 0x0010000UL;
1980 const U8BIT firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
1981 U8BIT *result, *pch;
1982 U16BIT bytesToWrite;
1983 U32BIT ch1, ch2, length;
1987 if ((src == NULL) || (src[UNICODE_HEADER_POS] != UTF16_HEADER_VALUE))
2010 DBGPRINT(
"ERR getting 3 * %d bytes", length);
2015 *result = UTF8_HEADER_VALUE;
2024 if (ch1 >= UNI_SUR_HIGH_START && ch1 <= UNI_SUR_HIGH_END)
2028 ch2 = (*src << 8) + *(src + 1);
2030 if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END)
2032 ch1 = ((ch1 - UNI_SUR_HIGH_START) << halfShift) + (ch2 - UNI_SUR_LOW_START) + halfBase;
2047 else if (ch1 >= UNI_SUR_LOW_START && ch1 <= UNI_SUR_LOW_END)
2054 if (ch1 < (U32BIT)0x80)
2058 else if (ch1 < (U32BIT)0x800)
2062 else if (ch1 < (U32BIT)0x10000)
2066 else if (ch1 < (U32BIT)0x110000)
2073 ch1 = UNI_REPLACEMENT_CHAR;
2075 pch += bytesToWrite;
2076 switch (bytesToWrite)
2078 case 4: *--pch = (U8BIT)((ch1 | byteMark) & byteMask); ch1 >>= 6;
2079 case 3: *--pch = (U8BIT)((ch1 | byteMark) & byteMask); ch1 >>= 6;
2080 case 2: *--pch = (U8BIT)((ch1 | byteMark) & byteMask); ch1 >>= 6;
2081 case 1: *--pch = (U8BIT) (ch1 | firstByteMark[bytesToWrite]);
2083 pch += bytesToWrite;
2090 *outlen = pch - result;
2116 U8BIT *ucode_string;
2128 if (ucode_string != NULL)
2130 byte_ptr = &ucode_string[1];
2131 for (i = 0; i < num_char; i++)
2133 char_code = (U16BIT)((*byte_ptr) << 8);
2135 char_code |= (U16BIT)(*byte_ptr);
2138 if ((char_code != 0x0020) && (char_code != 0x00a0))
2161 if (table < MAX_CHAR_MAP_TABLES)
2163 default_ascii_table = table;
2185 U32BIT str1_len, str2_len;
2189 S8BIT difference = STRINGS_EQUAL;
2193 if (string1_ptr != NULL)
2195 str1_len = strlen((
char *)string1_ptr);
2201 if (string2_ptr != NULL)
2203 str2_len = strlen((
char *)string2_ptr);
2210 if (str2_len < str1_len)
2212 min_str_len = str2_len;
2216 min_str_len = str1_len;
2219 for (index = 0; (index < min_str_len) && (difference == STRINGS_EQUAL); index++)
2221 char1 = *string1_ptr;
2222 char2 = *string2_ptr;
2224 if ((char1 >=
'A') && (char1 <=
'Z'))
2226 char1 =
'a' + (char1 -
'A');
2229 if ((char2 >=
'A') && (char2 <=
'Z'))
2231 char2 =
'a' + (char2 -
'A');
2236 difference = FIRST_STRING_GREATER;
2238 else if (char1 < char2)
2240 difference = SECOND_STRING_GREATER;
2247 if ((difference == STRINGS_EQUAL) && (str1_len != str2_len))
2249 if (str1_len < str2_len)
2251 difference = SECOND_STRING_GREATER;
2255 difference = FIRST_STRING_GREATER;
2293 BOOLEAN *reverse_dir,
2294 const U8BIT *
const format_ptr,
2297 typedef struct format_param
2299 U16BIT format_index;
2304 struct format_param *next_ptr;
2308 U8BIT *uni_string_ptr;
2309 U8BIT *uni_format_ptr;
2311 U16BIT format_length;
2313 U16BIT total_length;
2314 BOOLEAN free_uni_format_ptr;
2317 U16BIT uni_cur_char;
2318 E_FORMAT_PARAM *uni_format_param_ptr;
2319 E_FORMAT_PARAM *uni_head_param_list_ptr;
2320 E_FORMAT_PARAM *uni_last_param_list_ptr;
2322 U16BIT cur_format_index;
2329 U8BIT ascii_string[MAX_NUMBER_DIGITS + 1];
2330 U16BIT uni_next_char;
2332 U8BIT *tmp_format_ptr;
2333 U8BIT num_form_spec_str[MAX_NUM_FORMAT_SPEC_STR_SIZE];
2334 U8BIT num_form_spec_str_index;
2338 ASSERT(reverse_dir != NULL);
2341 va_start(args_ptr, format_ptr);
2342 *reverse_dir = FALSE;
2343 uni_string_ptr = NULL;
2344 uni_head_param_list_ptr = NULL;
2345 uni_format_param_ptr = NULL;
2346 uni_last_param_list_ptr = NULL;
2349 uni_format_ptr = (U8BIT *)format_ptr;
2351 MakeUnicode( &uni_format_ptr, &free_uni_format_ptr, &format_length, &reverse,
2352 strip_DVB_cntrl_char);
2354 total_length = format_length;
2355 *reverse_dir |= reverse;
2358 if (uni_format_ptr != NULL)
2362 for (format_loop = 0;
2363 (format_loop < (format_length - 1)) && (error_exit == FALSE);
2370 if (uni_cur_char == UNI_PERCENT_CHAR)
2372 cur_format_index = format_loop + 1;
2379 if (uni_cur_char == UNI_SMALL_S_CHAR)
2382 sizeof(E_FORMAT_PARAM));
2383 if (uni_format_param_ptr != NULL)
2386 if (uni_head_param_list_ptr == NULL)
2388 uni_head_param_list_ptr = uni_format_param_ptr;
2389 uni_last_param_list_ptr = uni_format_param_ptr;
2393 uni_last_param_list_ptr->next_ptr = uni_format_param_ptr;
2394 uni_last_param_list_ptr = uni_format_param_ptr;
2396 uni_format_param_ptr->format_index = (2 * format_loop) + 1;
2397 uni_format_param_ptr->format_adj = 2 * 2;
2398 uni_format_param_ptr->param = (U8BIT *) va_arg(args_ptr,
char *);
2399 MakeUnicode( &(uni_format_param_ptr->param),
2400 &(uni_format_param_ptr->free_param), &(uni_format_param_ptr->param_size),
2401 &reverse, strip_DVB_cntrl_char);
2402 uni_format_param_ptr->next_ptr = NULL;
2403 total_length = ((total_length - 2) +
2404 (uni_format_param_ptr->param_size));
2405 uni_format_param_ptr = uni_format_param_ptr->next_ptr;
2406 format_loop = cur_format_index;
2407 *reverse_dir |= reverse;
2418 memset((
void *)num_form_spec_str, 0,
sizeof(num_form_spec_str));
2419 num_form_spec_str[0] =
'%';
2420 num_form_spec_str_index = 1;
2423 while (((U8BIT)uni_cur_char >=
'0' && (U8BIT)uni_cur_char <=
'9') && (num_form_spec_str_index <= MAX_NUM_WIDTH_DIGITS))
2426 num_form_spec_str[num_form_spec_str_index] = (U8BIT)uni_cur_char;
2427 num_form_spec_str_index++;
2431 if ((atoi((
char *)&num_form_spec_str[1]) <= MAX_NUMBER_DIGITS)
2433 ((cur_format_index + 1) <= format_length))
2441 uni_cur_char = 0xffff;
2445 switch (uni_cur_char)
2448 case UNI_PERCENT_CHAR:
2451 if (num_form_spec_str_index == 1)
2454 snprintf((
char *)ascii_string, MAX_NUMBER_DIGITS + 1,
"%%");
2460 case UNI_SMALL_U_CHAR:
2461 case UNI_SMALL_D_CHAR:
2462 case UNI_SMALL_X_CHAR:
2463 case UNI_LARGE_X_CHAR:
2466 length_adj = num_form_spec_str_index + 1;
2467 num_form_spec_str[num_form_spec_str_index] = (U8BIT)uni_cur_char;
2468 if (uni_cur_char == UNI_SMALL_D_CHAR)
2470 s16_number = (S16BIT) va_arg(args_ptr,
int);
2471 snprintf((
char *)ascii_string, MAX_NUMBER_DIGITS + 1, (
char *)num_form_spec_str, s16_number );
2475 u16_number = (U16BIT) va_arg(args_ptr,
int);
2476 snprintf((
char *)ascii_string, MAX_NUMBER_DIGITS + 1, (
char *)num_form_spec_str, u16_number );
2482 case UNI_SMALL_H_CHAR:
2483 case UNI_SMALL_L_CHAR:
2486 if ((cur_format_index + 1) <= format_length)
2491 length_adj = num_form_spec_str_index + 2;
2492 num_form_spec_str[num_form_spec_str_index] = (U8BIT)uni_cur_char;
2493 num_form_spec_str_index++;
2494 num_form_spec_str[num_form_spec_str_index] = (U8BIT)uni_next_char;
2498 switch ((U32BIT)((uni_cur_char << 16) | uni_next_char))
2501 case UNI_SMALL_L_SMALL_U_CHARS:
2502 case UNI_SMALL_L_SMALL_X_CHARS:
2503 case UNI_SMALL_L_LARGE_X_CHARS:
2505 u32_number = (U32BIT) va_arg(args_ptr,
int);
2506 snprintf((
char *)ascii_string, MAX_NUMBER_DIGITS + 1, (
char *)num_form_spec_str, u32_number );
2511 case UNI_SMALL_H_SMALL_U_CHARS:
2512 case UNI_SMALL_H_SMALL_X_CHARS:
2513 case UNI_SMALL_H_LARGE_X_CHARS:
2515 u8_number = (U8BIT) va_arg(args_ptr,
int);
2516 snprintf((
char *)ascii_string, MAX_NUMBER_DIGITS + 1, (
char *)num_form_spec_str, u8_number );
2521 case UNI_SMALL_L_SMALL_D_CHARS:
2523 s32_number = (S32BIT) va_arg(args_ptr,
int);
2524 snprintf((
char *)ascii_string, MAX_NUMBER_DIGITS + 1, (
char *)num_form_spec_str, s32_number );
2529 case UNI_SMALL_H_SMALL_D_CHARS:
2531 s8_number = (S8BIT) va_arg(args_ptr,
int);
2532 snprintf((
char *)ascii_string, MAX_NUMBER_DIGITS + 1, (
char *)num_form_spec_str, s8_number );
2557 if (length_adj != 0)
2560 sizeof(E_FORMAT_PARAM));
2561 if (uni_format_param_ptr != NULL)
2564 if (uni_head_param_list_ptr == NULL)
2566 uni_head_param_list_ptr = uni_format_param_ptr;
2567 uni_last_param_list_ptr = uni_format_param_ptr;
2571 uni_last_param_list_ptr->next_ptr = uni_format_param_ptr;
2572 uni_last_param_list_ptr = uni_format_param_ptr;
2574 uni_format_param_ptr->format_index = (2 * format_loop) + 1;
2575 uni_format_param_ptr->format_adj = 2 * length_adj;
2576 uni_format_param_ptr->param = ascii_string;
2577 MakeUnicode( &(uni_format_param_ptr->param),
2578 &(uni_format_param_ptr->free_param), &(uni_format_param_ptr->param_size),
2580 uni_format_param_ptr->next_ptr = NULL;
2581 total_length = ((total_length - length_adj) +
2582 (uni_format_param_ptr->param_size));
2583 uni_format_param_ptr = uni_format_param_ptr->next_ptr;
2584 *reverse_dir |= reverse;
2591 format_loop = cur_format_index;
2596 if (error_exit == FALSE)
2599 uni_string_ptr = (U8BIT *)
STB_GetMemory(
sizeof(U8BIT) * STB_UTF16_LEN_TO_BYTES_IN_STRING(total_length));
2600 tmp_str_ptr = uni_string_ptr;
2601 if (uni_string_ptr != NULL)
2604 uni_format_param_ptr = uni_head_param_list_ptr;
2605 tmp_format_ptr = uni_format_ptr;
2606 while (tmp_str_ptr < (uni_string_ptr + STB_UTF16_LEN_TO_BYTES_IN_STRING(total_length)))
2608 if (uni_format_param_ptr != NULL)
2611 if ((tmp_format_ptr - uni_format_ptr) <
2612 uni_format_param_ptr->format_index)
2614 nchar = ((uni_format_param_ptr->format_index) - (tmp_format_ptr - uni_format_ptr));
2615 memcpy((
void *)tmp_str_ptr, (
void *)tmp_format_ptr, nchar);
2616 tmp_str_ptr += nchar;
2617 tmp_format_ptr += nchar;
2620 if (uni_format_param_ptr->param != NULL)
2622 memcpy((
void *)tmp_str_ptr,
2623 (
void *)((uni_format_param_ptr->param) + 1),
2624 2 * (uni_format_param_ptr->param_size));
2626 tmp_str_ptr += (2 * (uni_format_param_ptr->param_size));
2627 tmp_format_ptr += uni_format_param_ptr->format_adj;
2628 uni_format_param_ptr = uni_format_param_ptr->next_ptr;
2633 nchar = (STB_UTF16_LEN_TO_BYTES_IN_STRING(format_length) - (tmp_format_ptr - uni_format_ptr));
2634 memcpy((
void *)tmp_str_ptr, (
void *)tmp_format_ptr, nchar);
2635 tmp_str_ptr += nchar;
2636 tmp_format_ptr += nchar;
2645 uni_string_ptr = NULL;
2650 if (free_uni_format_ptr == TRUE)
2655 while (uni_head_param_list_ptr != NULL)
2657 uni_format_param_ptr = uni_head_param_list_ptr;
2658 uni_head_param_list_ptr = uni_format_param_ptr->next_ptr;
2659 if (uni_format_param_ptr->free_param == TRUE)
2668 if (uni_string_ptr != NULL)
2673 uni_string_ptr = tmp_str_ptr;
2678 return(uni_string_ptr);
2706 if ((src_str != NULL) && (insert_str != NULL))
2716 num_bytes = STB_UTF16_LEN_TO_BYTES_IN_STRING(num_chars);
2726 uni_insert = insert_str;
2733 if ((uni_src != NULL) && (uni_insert != NULL))
2740 if (new_str != NULL)
2743 num_bytes = (insert_pos * 2) + 1;
2744 memcpy(new_str, uni_src, num_bytes);
2745 str_ptr = new_str + num_bytes;
2749 memcpy(str_ptr, uni_insert + 1, num_bytes);
2750 str_ptr += num_bytes;
2760 memcpy(str_ptr, uni_src + (insert_pos * 2) + 1, num_bytes);
2764 if ((uni_insert != NULL) && (uni_insert != insert_str))
2769 if ((uni_src != NULL) && (uni_src != src_str))
2808 if (out_string != NULL)
2810 out_ptr = out_string;
2811 str_ptr = string_ptr;
2812 end_ptr = string_ptr + num_bytes;
2814 *out_ptr = *str_ptr;
2818 if (string_ptr[UNICODE_HEADER_POS] == UTF16_HEADER_VALUE)
2820 while (str_ptr < end_ptr)
2822 unicode = ((*str_ptr) << 8) | *(str_ptr + 1);
2825 if ((unicode != 0x008a) && (unicode != 0xe08a) && (unicode != 0x0086) &&
2826 (unicode != 0xe086) && (unicode != 0x0087) && (unicode != 0xe087))
2828 *out_ptr = (U8BIT)((unicode >> 8) & 0xff);
2830 *out_ptr = (U8BIT)(unicode & 0xff);
2837 while (str_ptr < end_ptr)
2839 unicode = ReadUTF8(&str_ptr);
2841 if ((unicode != 0x008a) && (unicode != 0xe08a) && (unicode != 0x0086) &&
2842 (unicode != 0xe086) && (unicode != 0x0087) && (unicode != 0xe087))
2844 out_ptr = OutputUTF8(out_ptr, unicode);
2875 static BOOLEAN CheckUnicodeCharForReverseDirection(U16BIT unicode)
2879 FUNCTION_START(CheckUnicodeCharForReverseDirection);
2883 if (((unicode >= 0x0600) && (unicode <= 0x06ff)) ||
2884 ((unicode >= 0xfb50) && (unicode <= 0xfdff)) ||
2885 ((unicode >= 0xfe70) && (unicode <= 0xfeff))
2891 FUNCTION_FINISH(CheckUnicodeCharForReverseDirection);
2910 static void MakeUnicode( U8BIT **addr_string_ptr, BOOLEAN *new_string, U16BIT *length_ptr,
2911 BOOLEAN *reverse_dir, BOOLEAN strip_DVB_cntrl_char)
2913 FUNCTION_START(MakeUnicode);
2915 *new_string = FALSE;
2916 if (*addr_string_ptr[UNICODE_HEADER_POS] != UTF16_HEADER_VALUE)
2919 strip_DVB_cntrl_char, 0);
2920 if (*addr_string_ptr == NULL)
2922 *new_string = FALSE;
2934 FUNCTION_FINISH(MakeUnicode);
2943 static U8BIT* OutputUTF8(U8BIT *buffer, U32BIT char_code)
2946 const U8BIT firstByteMark[4] = { 0x00, 0xC0, 0xE0, 0xF0 };
2948 FUNCTION_START(OutputUTF8);
2950 if (char_code < 0x80)
2954 else if (char_code < 0x0800)
2958 else if (char_code < 0x00010000)
2962 else if (char_code < 0x00110000)
2969 char_code = UNI_REPLACEMENT_CHAR;
2972 buffer += num_bytes;
2977 *buffer = (U8BIT)((char_code | 0x80) & 0xBF);
2981 *buffer = (U8BIT)((char_code | 0x80) & 0xBF);
2985 *buffer = (U8BIT)((char_code | 0x80) & 0xBF);
2989 *buffer = (U8BIT)(char_code | firstByteMark[num_bytes]);
2993 FUNCTION_FINISH(OutputUTF8);
2996 return(buffer + num_bytes + 1);
3005 static U32BIT ReadUTF8(U8BIT **buffer)
3010 FUNCTION_START(ReadUTF8);
3012 byte_val = (*buffer)[0];
3013 char_code = INVALID_UNICODE_CHAR;
3015 if ((byte_val & 0x80) == 0)
3017 char_code = byte_val;
3020 else if ((byte_val & 0xE0) == 0xC0)
3022 char_code = byte_val & 0x1F;
3024 char_code += (((*buffer)[1]) & 0x3F);
3027 else if ((byte_val & 0xF0) == 0xE0)
3029 char_code = byte_val & 0x0F;
3031 char_code += (((*buffer)[1]) & 0x3F);
3033 char_code += (((*buffer)[2]) & 0x3F);
3036 else if ((byte_val & 0xF8) == 0xF0)
3038 char_code = byte_val & 0x07;
3040 char_code += (((*buffer)[1]) & 0x3F);
3042 char_code += (((*buffer)[2]) & 0x3F);
3044 char_code += (((*buffer)[3]) & 0x3F);
3048 FUNCTION_FINISH(ReadUTF8);
3058 static U32BIT CharToLower(U32BIT char_code)
3060 FUNCTION_START(CharToLower);
3062 if (((char_code >=
'A') && (char_code <=
'Z')) ||
3063 ((char_code >= UC_LATIN_CAPITAL_LETTER_A_WITH_GRAVE) &&
3064 (char_code <= UC_LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS)) ||
3065 ((char_code >= UC_LATIN_CAPITAL_LETTER_O_WITH_STROKE) &&
3066 (char_code <= UC_LATIN_CAPITAL_LETTER_THORN)))
3070 else if ((char_code >= UC_LATIN_CAPITAL_LETTER_A_WITH_MACRON) &&
3071 (char_code <= UC_LATIN_CAPITAL_LETTER_Z_WITH_CARON))
3074 char_code = lowercase_chars_0x0100[char_code - UC_LATIN_CAPITAL_LETTER_A_WITH_MACRON];
3076 else if (char_code == UC_GREEK_CAPITAL_LETTER_ALPHA_WITH_TONOS)
3078 char_code = UC_GREEK_SMALL_LETTER_ALPHA_WITH_TONOS;
3080 else if ((char_code >= UC_GREEK_CAPITAL_LETTER_EPSILON_WITH_TONOS) &&
3081 (char_code <= UC_GREEK_CAPITAL_LETTER_IOTA_WITH_TONOS))
3085 else if (char_code == UC_GREEK_CAPITAL_LETTER_OMICRON_WITH_TONOS)
3087 char_code = UC_GREEK_SMALL_LETTER_OMICRON_WITH_TONOS;
3089 else if (char_code == UC_GREEK_CAPITAL_LETTER_UPSILON_WITH_TONOS)
3091 char_code = UC_GREEK_SMALL_LETTER_UPSILON_WITH_TONOS;
3093 else if (char_code == UC_GREEK_CAPITAL_LETTER_OMEGA_WITH_TONOS)
3095 char_code = UC_GREEK_SMALL_LETTER_OMEGA_WITH_TONOS;
3097 else if ((char_code >= UC_GREEK_CAPITAL_LETTER_ALPHA) &&
3098 (char_code <= UC_GREEK_CAPITAL_LETTER_UPSILON_WITH_DIALYTIKA))
3102 else if ((char_code >= UC_CYRILLIC_CAPITAL_LETTER_IO) && (char_code <= UC_CYRILLIC_CAPITAL_LETTER_DZHE))
3106 else if ((char_code >= UC_CYRILLIC_CAPITAL_LETTER_A) && (char_code <= UC_CYRILLIC_CAPITAL_LETTER_YA))
3110 else if ((char_code >= UC_LATIN_CAPITAL_LETTER_A_WITH_RING_BELOW) &&
3111 (char_code <= UC_LATIN_CAPITAL_LETTER_Y_WITH_LOOP))
3113 char_code = lowercase_chars_0x1E00[char_code - UC_LATIN_CAPITAL_LETTER_A_WITH_RING_BELOW];
3116 FUNCTION_FINISH(CharToLower);
Contains character map tables for converting single byte ascii codes above 0xa0 to unicode codes...
void * STB_GetMemory(U32BIT bytes)
Attempts to allocate memory from the heap.
U8BIT * STB_SetUnicodeStringChar(U8BIT *string_ptr, U16BIT char_id, U16BIT code)
Takes a string and changes the requested location to a new value. This request may involve appending ...
void STB_SetDefaultAsciiTable(U8BIT table)
Sets default ascii table to be used, if not overridden by the table index at the start of a string...
U8BIT * STB_ConvertStringToUTF8(U8BIT *string, U16BIT *nchar, BOOLEAN strip_DVB_cntrl_char, U32BIT lang_code)
Converts the given DVB coded string into a UTF-8 unicode string. The returned string will be preceded...
U8BIT * STB_ConvertUTF16toUTF8(U8BIT *src, U32BIT *outlen)
Creates the given string from UTF-16 to UTF-8 and returns a new string. The returned string should be...
S8BIT STB_CompareUnicodeStrings(U8BIT *string1_ptr, U8BIT *string2_ptr, BOOLEAN exact_match, BOOLEAN ignore_case)
Compares the contents of the two given unicode strings and returns the status (as per strcmp) ...
U8BIT * STB_ConvertStringToUnicode(U8BIT *string, BOOLEAN *reverse_dir, U16BIT *nchar, BOOLEAN strip_DVB_cntrl_char, U32BIT lang_code)
Converts the specified DVB coded string into a unicode string, counting the number of characters and ...
void * STB_ResizeMemory(void *ptr, U32BIT new_num_bytes)
Re-allocates a given memory area to the new size, ensuring data contained within the original memory ...
U8BIT * STB_FormatUnicodeString(BOOLEAN strip_DVB_cntrl_char, BOOLEAN *reverse_dir, const U8BIT *const format_ptr,...)
Unicode version of sprintf.
S8BIT STB_CompareStringsIgnoreCase(U8BIT *string1_ptr, U8BIT *string2_ptr)
Compares the contents of the two given ASCII strings and returns the status (as per strcmp) but ignor...
void STB_FreeMemory(void *addr)
Releases previously allocated heap memory.
BOOLEAN STB_IsStringEmpty(U8BIT *string_ptr)
Checks for a string of only spaces.
Debug functions header file.
void STB_ReleaseUnicodeString(U8BIT *string)
Releases the specified unicode string, freeing associated heap resources.
U8BIT * STB_UnicodeStripControlChars(U8BIT *string_ptr)
Strips the DVB control characters from a string that's already in UTF-8 or UTF-16 format...
U32BIT STB_UnicodeStringLen(U8BIT *string_ptr)
Determines the length, in characters, of the given unicode string by searching for NULL...
BOOLEAN STB_IsNormalString(U8BIT *string_ptr)
Tests for normal ascii string.
Header for STB unicode string handling routines.
U8BIT * STB_DeleteUnicodeStringChar(U8BIT *string_ptr, U16BIT char_id)
Takes a string and removes the requested location, shuffling any following data down (thus removing g...
U8BIT * STB_ConcatUnicodeStrings(U8BIT *string1_ptr, U8BIT *string2_ptr)
Appends the contents of string2_ptr to string1_ptr and returns a pointer to the newly created string...
System Wide Global Technical Data Type Definitions.
U16BIT STB_HuffmanDecompress(U8BIT encoding_type, U8BIT *input, U8BIT *output, U16BIT output_size)
Decompresses the input buffer according to the BBC's Huffman algorithm as defined in the DTG D-Book 6...
Header file - Function prototypes for heap memory.
U32BIT STB_GetUnicodeStringChar(U8BIT *string_ptr, U16BIT char_id)
Retrieves the unicode value pointed to by char_id within the given string. If an invalid request occu...
U8BIT * STB_UnicodeStrStr(U8BIT *str1, U8BIT *str2, BOOLEAN ignore_case)
Finds the first occurence of str2 in str1 and returns a pointer to the substring (as per strstr) ...
BOOLEAN STB_IsUnicodeString(U8BIT *string_ptr)
Tests for unicode string.
U32BIT STB_GetNumBytesInString(U8BIT *string_ptr)
Determines the no of bytes of the given string.
BOOLEAN STB_IsUnicodeStringReversed(U8BIT *string_ptr)
Checks to see if the supplied string is unicode and if it is reversed (arabic)
U8BIT * STB_UnicodeStringTokenise(U8BIT *string, U8BIT **save_ptr)
Divides the (space separated) string up into individual words and returns them one per call...
STB midware Huffman decompression routines defined by the BBC.
U8BIT * STB_UnicodeInsertString(U8BIT *src_str, U16BIT insert_pos, U8BIT *insert_str, BOOLEAN replace_char)
Creates a new string by inserting one string into another at a given position, with the option of rep...