Skip to content

Commit

Permalink
hotplug_macosx: handle UTF-8 in ifdFriendlyName
Browse files Browse the repository at this point in the history
If CFStringGetCStringPtr() fails then we try to copy the sting using
kCFStringEncodingUTF8 encoding.

This allows to get reader friendly name like "SoloKeys Solo 🐝".
  • Loading branch information
LudovicRousseau committed May 16, 2020
1 parent 6d0b167 commit 047789c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/hotplug_macosx.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,17 @@ static HPDriverVector HPDriversGetFromDirectory(const char *driverBundlePath)
const char *cstr = CFStringGetCStringPtr(strValue,
CFStringGetSystemEncoding());
if (NULL == cstr)
continue;
{
char utf8_str[200];
if (CFStringGetCString(strValue, utf8_str, sizeof utf8_str,
kCFStringEncodingUTF8))
driverBundle->m_friendlyName = strdup(utf8_str);
else
continue;
}
else
driverBundle->m_friendlyName = strdup(cstr);

driverBundle->m_friendlyName = strdup(cstr);
if (!driverBundle->m_libPath)
driverBundle->m_libPath = strdup(libPath);

Expand Down

0 comments on commit 047789c

Please sign in to comment.