Unicode USB strings conversion
- From: Nick Hibma <nick@xxxxxxxxxxxxxxxxx>
- Date: Wed, 19 Nov 2008 08:42:58 +0100
In the USB code (and I bet it is the same in the USB4BSD code) unicode
characters in strings are converted in a very crude way to ASCII. As I have
a user on the line who sees rubbish in his logs and when using
usbctl/usbdevs/etc., I bet this is the problem.
I'd like to try and fix this problem by using libkern/libiconv.
1) Is this the right approach to convert UTF8 to printable string in the
kernel?
2) Is this needed at all in the short term future? I remember seeing
attempts at making the kernel use UTF8.
3) Does anyone know of a good example in the code without me having to hunt
through the kernel to find it?
For reference: The code that needs replacing is:
usbd_get_string():
s = buf;
n = size / 2 - 1;
for (i = 0; i < n && i < len - 1; i++) {
c = UGETW(us.bString[i]);
/* Convert from Unicode, handle buggy strings. */
if ((c & 0xff00) == 0)
*s++ = c;
else if ((c & 0x00ff) == 0 && swap)
*s++ = c >> 8;
else
*s++ = '?';
}
*s++ = 0;
I haven't got the USB specs handy, but I believe that this is a simple way
of converting LE and BE UTF8 to ASCII.
Nick
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: Unicode USB strings conversion
- From: Tim Kientzle
- Re: Unicode USB strings conversion
- From: Hans Petter Selasky
- Re: Unicode USB strings conversion
- Prev by Date: RE: How can I add new binaries to the mfsroot image?
- Next by Date: Re: Unicode USB strings conversion
- Previous by thread: What are proper install.cfg for configuring multiple slices?
- Next by thread: Re: Unicode USB strings conversion
- Index(es):
Relevant Pages
|