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