* commands/usbtest.c (grub_usb_get_string): Properly support UTF-16.
This commit is contained in:
parent
f24f430030
commit
db4d5813e3
2 changed files with 16 additions and 3 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
2010-05-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* commands/usbtest.c (grub_usb_get_string): Properly support UTF-16.
|
||||||
|
|
||||||
2010-05-23 Vladimir Serbinenko <phcoder@gmail.com>
|
2010-05-23 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
cmostest support.
|
cmostest support.
|
||||||
|
|
|
@ -83,15 +83,24 @@ grub_usb_get_string (grub_usb_device_t dev, grub_uint8_t index, int langid,
|
||||||
0x06, (3 << 8) | index,
|
0x06, (3 << 8) | index,
|
||||||
langid, descstr.length, (char *) descstrp);
|
langid, descstr.length, (char *) descstrp);
|
||||||
|
|
||||||
*string = grub_malloc (descstr.length / 2);
|
if (descstrp->length == 0)
|
||||||
|
{
|
||||||
|
grub_free (descstrp);
|
||||||
|
*string = grub_strdup ("");
|
||||||
|
if (! *string)
|
||||||
|
return GRUB_USB_ERR_INTERNAL;
|
||||||
|
return GRUB_USB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*string = grub_malloc (descstr.length * 2 + 1);
|
||||||
if (! *string)
|
if (! *string)
|
||||||
{
|
{
|
||||||
grub_free (descstrp);
|
grub_free (descstrp);
|
||||||
return GRUB_USB_ERR_INTERNAL;
|
return GRUB_USB_ERR_INTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_utf16_to_utf8 ((grub_uint8_t *) *string, descstrp->str, descstrp->length / 2 - 1);
|
*grub_utf16_to_utf8 ((grub_uint8_t *) *string, descstrp->str,
|
||||||
(*string)[descstr.length / 2 - 1] = '\0';
|
descstrp->length / 2 - 1) = 0;
|
||||||
grub_free (descstrp);
|
grub_free (descstrp);
|
||||||
|
|
||||||
return GRUB_USB_ERR_NONE;
|
return GRUB_USB_ERR_NONE;
|
||||||
|
|
Loading…
Reference in a new issue