After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 369413 - Scandinavian char in printer name breaks on Windows
Scandinavian char in printer name breaks on Windows
Status: RESOLVED FIXED
Product: gnome-print
Classification: Deprecated
Component: general
unspecified
Other Windows
: Normal normal
: ---
Assigned To: Jody Goldberg
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2006-11-02 13:26 UTC by Jon Kåre Hellan
Modified: 2006-11-03 15:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to fix the remaining encoding issues (3.74 KB, patch)
2006-11-02 18:16 UTC, Jon Kåre Hellan
none Details | Review

Description Jon Kåre Hellan 2006-11-02 13:26:03 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);
Comment 1 Jon Kåre Hellan 2006-11-02 13:29:29 UTC
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);
Comment 2 Jon Kåre Hellan 2006-11-02 16:13:51 UTC
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.
Comment 3 Morten Welinder 2006-11-02 16:30:47 UTC
I'd take a guess that the two applications of strncpy suffer the same
problem.
Comment 4 Morten Welinder 2006-11-02 16:32:57 UTC
And info2_arr->pLocation
Comment 5 Morten Welinder 2006-11-02 16:36:46 UTC
And the ->name here probably needs to be converted the other way.

if (!OpenPrinter (printer->name, &hPrinter, NULL))
Comment 6 Jon Kåre Hellan 2006-11-02 18:16:48 UTC
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
Comment 7 Jon Kåre Hellan 2006-11-03 15:53:14 UTC
Tested. Fix committed.