我正在为嵌入式系统创建一个 UTF8 表查找。该表用于将 UTF8 编码字符转换为字体(数组)中的位图索引。
我收到警告“多字符字符文字(潜在的可移植性问题)”。“conversion_table”数组中的每个条目都带有此警告标记。
这是代码:
typedef struct UTF8_To_Bitmap_Index_s
{
char16_t encoded_character;
uint8_t bitmap_index;
} UTF8_To_Bitmap_Index_t;
size_t width_wchar_t = sizeof(wchar_t);
UTF8_To_Bitmap_Index_t conversion_table[] =
{
{'¡', 0x00},
{'À', 0x00},
{'Á', 0x00},
{'Ã', 0x00},
{'Ä', 0x00},
{'Å', 0x00},
{'Ç', 0x00},
{'É', 0x00},
{'Í', 0x00},
{'Ó', 0x00},
{'Õ', 0x00},
{'Ö', 0x00},
{'Ø', 0x00},
{'Ú', 0x00},
{'Ü', 0x00},
{'ß', 0x00},
{'à', 0x00},
{'á', 0x00},
{'â', 0x00},
{'ã', 0x00},
{'ä', 0x00},
{'å', 0x00},
{'æ', 0x00},
{'ç', 0x00},
{'è', 0x00},
{'é', 0x00},
{'ê', 0x00},
{'í', 0x00},
{'ñ', 0x00},
{'ó', 0x00},
{'ô', 0x00},
};
有什么方法可以更改上述代码以消除警告?
(注意:在0x00
确定实际位图索引之前,它是一个占位符。)
生成的数据是正确的:
50 UTF8_To_Bitmap_Index_t conversion_table[] =
\ conversion_table:
\ 00000000 0xC2A1 DC16 49825
\ 00000002 0x00 0x00 DC8 0, 0
\ 00000004 0xC380 DC16 50048
\ 00000006 0x00 0x00 DC8 0, 0
\ 00000008 0xC381 DC16 50049
\ 0000000A 0x00 0x00 DC8 0, 0
\ 0000000C 0xC383 DC16 50051
\ 0000000E 0x00 0x00 DC8 0, 0
\ 00000010 0xC384 DC16 50052
\ 00000012 0x00 0x00 DC8 0, 0
\ 00000014 0xC385 DC16 50053
\ 00000016 0x00 0x00 DC8 0, 0
\ 00000018 0xC387 DC16 50055
\ 0000001A 0x00 0x00 DC8 0, 0
\ 0000001C 0xC389 DC16 50057
\ 0000001E 0x00 0x00 DC8 0, 0
\ 00000020 0xC38D DC16 50061
\ 00000022 0x00 0x00 DC8 0, 0
\ 00000024 0xC393 DC16 50067
\ 00000026 0x00 0x00 DC8 0, 0
\ 00000028 0xC395 DC16 50069
\ 0000002A 0x00 0x00 DC8 0, 0
\ 0000002C 0xC396 DC16 50070
\ 0000002E 0x00 0x00 DC8 0, 0
\ 00000030 0xC398 DC16 50072
\ 00000032 0x00 0x00 DC8 0, 0
\ 00000034 0xC39A DC16 50074
\ 00000036 0x00 0x00 DC8 0, 0
\ 00000038 0xC39C DC16 50076
\ 0000003A 0x00 0x00 DC8 0, 0
\ 0000003C 0xC39F DC16 50079
\ 0000003E 0x00 0x00 DC8 0, 0
\ 00000040 0xC3A0 DC16 50080
\ 00000042 0x00 0x00 DC8 0, 0
\ 00000044 0xC3A1 DC16 50081
\ 00000046 0x00 0x00 DC8 0, 0
\ 00000048 0xC3A2 DC16 50082
\ 0000004A 0x00 0x00 DC8 0, 0
\ 0000004C 0xC3A3 DC16 50083
\ 0000004E 0x00 0x00 DC8 0, 0
\ 00000050 0xC3A4 DC16 50084
\ 00000052 0x00 0x00 DC8 0, 0
\ 00000054 0xC3A5 DC16 50085
\ 00000056 0x00 0x00 DC8 0, 0
\ 00000058 0xC3A6 DC16 50086
\ 0000005A 0x00 0x00 DC8 0, 0
\ 0000005C 0xC3A7 DC16 50087
\ 0000005E 0x00 0x00 DC8 0, 0
\ 00000060 0xC3A8 DC16 50088
\ 00000062 0x00 0x00 DC8 0, 0
\ 00000064 0xC3A9 DC16 50089
\ 00000066 0x00 0x00 DC8 0, 0
\ 00000068 0xC3AA DC16 50090
\ 0000006A 0x00 0x00 DC8 0, 0
\ 0000006C 0xC3AD DC16 50093
\ 0000006E 0x00 0x00 DC8 0, 0
\ 00000070 0xC3B1 DC16 50097
\ 00000072 0x00 0x00 DC8 0, 0
\ 00000074 0xC3B3 DC16 50099
\ 00000076 0x00 0x00 DC8 0, 0
\ 00000078 0xC3B4 DC16 50100
\ 0000007A 0x00 0x00 DC8 0, 0
资源:
编译器——IAR Embedded Workbench 7.4 版
目标平台:ARM Cortex M