... | ... | @@ -196,20 +196,20 @@ a multi-byte string to a Unicode string under the specified white space |
|
|
rule. For example, you can convert a general C string in `UTF-8` or
|
|
|
`GB18030` charset to a `Uchar32` string by calling this function.
|
|
|
|
|
|
```
|
|
|
LOGFONT* lf;
|
|
|
int left_len_text;
|
|
|
```C
|
|
|
LOGFONT* lf;
|
|
|
int left_len_text;
|
|
|
|
|
|
char* text = "中华人民共和国万岁!\n中国共产党万岁!";
|
|
|
char* text = "中华人民共和国万岁!\n中国共产党万岁!";
|
|
|
|
|
|
if (!(lf = CreateLogFontForMChar2UChar("utf-8"))) {
|
|
|
if (!(lf = CreateLogFontForMChar2UChar("utf-8"))) {
|
|
|
_ERR_PRINTF("%s: failed to create logfont for utf-8 charset\n",
|
|
|
__FUNCTION__);
|
|
|
exit(1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
left_len_text = strlen(text);
|
|
|
while (left_len_text > 0) {
|
|
|
left_len_text = strlen(text);
|
|
|
while (left_len_text > 0) {
|
|
|
Uchar32* ucs = NULL;
|
|
|
int consumed, n;
|
|
|
|
... | ... | @@ -227,9 +227,9 @@ rule. For example, you can convert a general C string in `UTF-8` or |
|
|
|
|
|
text += consumed;
|
|
|
left_len_text -= consumed;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
DestroyLogFont(lf);
|
|
|
DestroyLogFont(lf);
|
|
|
```
|
|
|
|
|
|
In the above code, we call `CreateLogFontForMChar2UChar` function to create
|
... | ... | |