Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_cupsLangPrintf() doesn't print with en_US.ASCII locale #3832

Closed
michaelrsweet opened this issue Apr 18, 2011 · 5 comments
Closed

_cupsLangPrintf() doesn't print with en_US.ASCII locale #3832

michaelrsweet opened this issue Apr 18, 2011 · 5 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.4.6
CUPS.org User: jpopelka

Binaries (all from systemv directory) using _cupsLangPrintf()
don't print anything out when locale is set to en_US.ASCII

Problem is that there's no us-ascii.txt data file so
cupsUTF8ToCharset(encoding = CUPS_US_ASCII)
can't transcode to ASCII.

I have no idea whether this is a bug or designed so.
Work-around could be to treat CUPS_US_ASCII the same way as other "unknown" encoding. See attached patch.

See also original bug report
https://bugzilla.redhat.com/show_bug.cgi?id=681836

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Jiri,

The simplest fix for 1.4.x is probably just to map ASCII to ISO-8859-1 in the transcoding code; for CUPS 1.5 we actually switched to using iconv so the "right" things will happen.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

A 1.4.x and 1.5.x version of the fix is attached; the charset->UTF-8 mapping using the UTF-8 "identity" path, while the UTF-8->charset mapping uses a modified version of the ISO-8859-1 "fast" path (which will map unicode characters to "?").

@michaelrsweet
Copy link
Collaborator Author

"cups-1.4.6-ascii.patch":

diff -up cups-1.4.6/cups/language.c.ascii cups-1.4.6/cups/language.c
--- cups-1.4.6/cups/language.c.ascii 2010-08-10 08:15:55.000000000 +0200
+++ cups-1.4.6/cups/language.c 2011-04-18 16:33:59.000000000 +0200
@@ -670,6 +670,9 @@ cupsLangGet(const char language) / I -
break;
}

  • if (encoding == CUPS_US_ASCII)
  •  encoding = CUPS_AUTO_ENCODING;
    
    if (encoding == CUPS_AUTO_ENCODING)
    {
    /*

@michaelrsweet
Copy link
Collaborator Author

"str3832.patch":

Index: CHANGES-1.4.txt

--- CHANGES-1.4.txt (revision 9694)
+++ CHANGES-1.4.txt (working copy)
@@ -9,6 +9,8 @@
STR #3755, STR #3769, STR #3783)
- Configure script fixes (STR #3659, STR #3691)
- Compilation fixes (STR #3718, STR #3771, STR #3774)

    • CUPS did not work with locales using the ASCII character set
  • (STR #3832)
    
  • if (encoding == CUPS_UTF8 || encoding <= CUPS_US_ASCII ||
  • if (encoding == CUPS_UTF8 ||
    encoding >= CUPS_ENCODING_VBCS_END)
    {
    strlcpy(dest, (char *)src, maxout);
    @@ -243,12 +243,13 @@

destptr = dest;

  • if (encoding == CUPS_ISO8859_1)
  • if (encoding == CUPS_ISO8859_1 || encoding <= CUPS_US_ASCII)
    {
  • int ch; /* Character from string */
  • int ch, /* Character from string */
  •   maxch;          /\* Maximum character for charset _/
    
    char *destend; /_ End of ISO-8859-1 buffer */

  • maxch = encoding == CUPS_ISO8859_1 ? 256 : 128;
    destend = dest + maxout - 1;

while (_src && destptr < destend)
@@ -259,7 +260,7 @@
{
ch = ((ch & 0x1f) << 6) | (_src++ & 0x3f);

  • if (ch < 256)
  • if (ch < maxch)
    *destptr++ = ch;
    else
    *destptr++ = '?';

@michaelrsweet
Copy link
Collaborator Author

"str3832-1.4.patch":

Index: cups/transcode.c

--- cups/transcode.c (revision 9694)
+++ cups/transcode.c (working copy)
@@ -1,9 +1,9 @@
/*

  • "$Id$"
    *
    • * Transcoding support for the Common UNIX Printing System (CUPS).
    • * Transcoding support for CUPS.
      *
    • * Copyright 2007-2009 by Apple Inc.
    • * Copyright 2007-2011 by Apple Inc.
  • Copyright 1997-2007 by Easy Software Products.
  • These coded instructions, statements, and computer programs are the
    @@ -279,7 +279,7 @@
  • Handle identity conversions...
    */
  • if (encoding == CUPS_UTF8 ||
  • if (encoding == CUPS_UTF8 || encoding <= CUPS_US_ASCII ||
    encoding < 0 || encoding >= CUPS_ENCODING_VBCS_END)
    {
    strlcpy((char *)dest, src, maxout);
    @@ -385,13 +385,14 @@
  • Handle UTF-8 to ISO-8859-1 directly...
    */
  • if (encoding == CUPS_ISO8859_1)
  • if (encoding == CUPS_ISO8859_1 || encoding == CUPS_US_ASCII)
    {
  • int ch; /* Character from string */
  • int ch, /* Character from string */
  •   maxch;          /\* Maximum character for charset _/
    
    char *destptr, /_ Pointer into ISO-8859-1 buffer /
    *destend; /
    End of ISO-8859-1 buffer */

  • maxch = encoding == CUPS_ISO8859_1 ? 256 : 128;
    destptr = dest;
    destend = dest + maxout - 1;

@@ -403,7 +404,7 @@
{
ch = ((ch & 0x1f) << 6) | (*src++ & 0x3f);

  • if (ch < 256)
  • if (ch < maxch)
    *destptr++ = ch;
    else
    *destptr++ = '?';

Index: CHANGES.txt

--- CHANGES.txt (revision 9694)
+++ CHANGES.txt (working copy)
@@ -1,4 +1,4 @@
-CHANGES.txt - 2011-04-13

+CHANGES.txt - 2011-04-18

CHANGES IN CUPS V1.4.7
@@ -9,6 +9,8 @@
STR #3755, STR #3769, STR #3783)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant