All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bastien Nocera <hadess@hadess.net>
To: BlueZ development <linux-bluetooth@vger.kernel.org>
Subject: Work-around for broken MS device
Date: Thu, 05 Mar 2009 18:48:28 +0000	[thread overview]
Message-ID: <1236278908.3602.1896.camel@cookie.hadess.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 401 bytes --]

Heya,

As seen in https://bugzilla.redhat.com/show_bug.cgi?id=450081
The Microsoft Wireless Notebook Presenter Mouse 8000 has its name in
ISO-8859-1 instead of UTF-8, as required by the BT spec.

I've implemented a small work-around. This isn't very invasive, IMO, as
we already do UTF-8 checks.

In my tests, this makes the mouse show up as:
Microsoft® Wireless Notebook Presenter Mouse 8000

Cheers

[-- Attachment #2: bluez-try-utf8-harder.patch --]
[-- Type: text/x-patch, Size: 766 bytes --]

diff --git a/src/security.c b/src/security.c
index a61d75f..75908ba 100644
--- a/src/security.c
+++ b/src/security.c
@@ -600,8 +600,16 @@ static inline void remote_name_information(int dev, bdaddr_t *sba, void *ptr)
 		memcpy(name, evt->name, 248);
 		/* It's ok to cast end between const and non-const since
 		 * we know it points to inside of name which is non-const */
-		if (!g_utf8_validate(name, -1, (const char **) &end))
-			*end = '\0';
+		if (!g_utf8_validate(name, -1, (const char **) &end)) {
+			char *utf8_name;
+
+			utf8_name = g_convert(name, -1, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
+			if (utf8_name) {
+				memcpy(name, utf8_name, 248);
+				g_free(utf8_name);
+			} else
+				*end = '\0';
+		}
 		write_device_name(sba, &dba, name);
 	}
 

             reply	other threads:[~2009-03-05 18:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-05 18:48 Bastien Nocera [this message]
2009-03-18 17:27 ` [PATCH] Re: Work-around for broken MS device Bastien Nocera
2009-03-14  6:21   ` Marcel Holtmann
2009-03-23 13:59     ` Bastien Nocera
2009-03-23 15:45       ` Marcel Holtmann
2011-05-05 18:02         ` Bastien Nocera
2011-05-05 18:37           ` Bastien Nocera
2011-05-05 19:02             ` Johan Hedberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1236278908.3602.1896.camel@cookie.hadess.net \
    --to=hadess@hadess.net \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.