GNOME Bugzilla – Bug 369413
Scandinavian char in printer name breaks on Windows
Last modified: 2006-11-03 15:53:14 UTC
One of the printers on my kids' XP Home computer is a remote printer named 'Automatisk hp på PARUS'. When opening the print dialog in gnumeric, I get the following messages which are due to the non-ASCII printer name: Entity: line 1: parser error : Input is not proper UTF-8, indicate encoding ! <?xml version="1.0"?><Model Id="Win32-Automatisk hp p� PARUS" Version="1.0"> <N ^ Entity: line 1: error: Bytes: 0xE5 0x20 0x50 0x41 <?xml version="1.0"?><Model Id="Win32-Automatisk hp p� PARUS" Version="1.0"> <N ^ ** (c:\Gnumeric\bin\gnumeric.exe:3348): WARNING **: Could not parse model xml ** (c:\Gnumeric\bin\gnumeric.exe:3348): CRITICAL **: gpa_option_new: assertion `parent != NULL' failed ** (c:\Gnumeric\bin\gnumeric.exe:3348): CRITICAL **: gpa_option_new: assertion `parent != NULL' failed ** (c:\Gnumeric\bin\gnumeric.exe:3348): CRITICAL **: gpa_option_new: assertion `parent != NULL' failed ** (c:\Gnumeric\bin\gnumeric.exe:3348): CRITICAL **: gpa_option_new: assertion `parent != NULL' failed ** (c:\Gnumeric\bin\gnumeric.exe:3348): CRITICAL **: gpa_node_unref: assertion `node != NULL' failed ** (c:\Gnumeric\bin\gnumeric.exe:3348): CRITICAL **: gpa_node_unref: assertion `node != NULL' failed ** (c:\Gnumeric\bin\gnumeric.exe:3348): CRITICAL **: gpa_node_unref: assertion `node != NULL' failed (c:\Gnumeric\bin\gnumeric.exe:3348): GnomePrintWin32Plugin-WARNING **: model creation failed (c:\Gnumeric\bin\gnumeric.exe:3348): GnomePrintWin32Plugin-WARNING **: The printer Automatisk hp p\xe5 PARUS could not be created The string which fails to parse is created at l 431 in gnome-print-win32.c, function get_model: id = g_strdup_printf ("Win32-%s", info->pPrinterName); xml = g_strdup_printf ((char *)model_xml_template, id, info->pPrinterName); I'd suggest changing this to gchar *pname; pname = g_locale_to_utf8 (info->pPrinterName), -1, NULL, NULL, NULL); id = g_strdup_printf ("Win32-%s", name); xml = g_strdup_printf ((char *)model_xml_template, id, info->pPrinterName); .. g_free (pname);
Typo, of course. Make that gchar *pname; pname = g_locale_to_utf8 (info->pPrinterName), -1, NULL, NULL, NULL); id = g_strdup_printf ("Win32-%s", pname); xml = g_strdup_printf ((char *)model_xml_template, id, info->pPrinterName); .. g_free (pname);
Fix successfully tested, patch applied to HEAD. The printer now shows up, and you can print to it, but the name is truncated before the 'å'. Apparently there are more places which need the same fix.
I'd take a guess that the two applications of strncpy suffer the same problem.
And info2_arr->pLocation
And the ->name here probably needs to be converted the other way. if (!OpenPrinter (printer->name, &hPrinter, NULL))
Created attachment 75873 [details] [review] Patch to fix the remaining encoding issues Hopefully, this will fix the remaining encoding issues in gnome-print-win32.c
Tested. Fix committed.