You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
Java libraries are using iso-8859-1 for requests #2651
I refer to the java libraries in the CUPS source package, especially /scripting/java/src/com/easyws/cups/Cups.java.
The packages are using 'ISO-8859-1' to make requests to a CUPS server.
--- example ---
a = new IPPAttribute( IPPDefs.TAG_OPERATION, IPPDefs.TAG_CHARSET,
"attributes-charset" );
a.addString( "", "iso-8859-1" );
---/example ---
Any request to a CUPS server fails with the message 'unsupported character set "iso-8859-1"'.
As I have discovered, the cupsd only supports 'UTF-8'. The java sources should be fixed to 'UTF-8' to work correctly.
The code needed a little more than just the iso-8859-1 string changed; we also needed to encode the Java strings using UTF-8 (they are natively UTF-16) and could not just pass the low 8 bits like we were doing before...
Internet Printing Protocol definitions for the Common UNIX Printing
System (CUPS).
* Copyright 2007 by Apple Inc.
* Copyright 2007-2008 by Apple Inc.
Copyright 1997-2002 by Easy Software Products.
These coded instructions, statements, and computer programs are the
@@ -263,7 +263,9 @@
{
IPPValue val;
int bytes = 0; // Start with one for the group tag.
Charset utf8 = Charset::forName("UTF-8");
ByteBuffer temp;
+
//
// Add 1 if first time, or group tag changes.
//
@@ -308,8 +310,12 @@
case IPPDefs.TAG_CHARSET:
case IPPDefs.TAG_LANGUAGE:
case IPPDefs.TAG_MIMETYPE:
temp = utf8.encode(val.text);
bytes += 2;
bytes += val.text.length();
if (temp.capacity() > 32767)
bytes += 32767;
else
bytes += temp.capacity();
break;
case IPPDefs.TAG_DATE :
@@ -329,9 +335,13 @@
case IPPDefs.TAG_TEXTLANG :
case IPPDefs.TAG_NAMELANG :
temp = utf8.encode(val.text);
bytes += 6; // 2 overall len, 2 charset len, 2 text len
bytes += val.charset.length() +
val.text.length();
bytes += val.charset.length();
if (temp.capacity() > 32767)
bytes += 32767;
else
bytes += temp.capacity();
break;
default :
@@ -359,6 +369,8 @@
int i,j, n;
int bi = 0; // Start with one for the group tag.
byte[] bytes = new byte[sz];
Charset utf8 = Charset::forName("UTF-8");
ByteBuffer temp;
if (group_tag != last_group)
{
@@ -412,12 +424,16 @@
case IPPDefs.TAG_CHARSET :
case IPPDefs.TAG_LANGUAGE :
case IPPDefs.TAG_MIMETYPE :
Activity
michaelrsweet commentedon Jan 7, 2008
CUPS.org User: mike
Fixed in Subversion repository.
The code needed a little more than just the iso-8859-1 string changed; we also needed to encode the Java strings using UTF-8 (they are natively UTF-16) and could not just pass the low 8 bits like we were doing before...
michaelrsweet commentedon Jan 7, 2008
"str2651.patch":
Index: scripting/java/src/com/easysw/cups/Cups.java
--- scripting/java/src/com/easysw/cups/Cups.java (revision 7178)
+++ scripting/java/src/com/easysw/cups/Cups.java (working copy)
@@ -7,7 +7,7 @@
These coded instructions, statements, and computer programs are the
@@ -831,7 +831,7 @@
a = new IPPAttribute( IPPDefs.TAG_OPERATION, IPPDefs.TAG_CHARSET,
"attributes-charset" );
ipp.addAttribute(a);
@@ -1014,7 +1014,7 @@
@@ -1091,7 +1091,7 @@
@@ -1155,7 +1155,7 @@
@@ -1229,7 +1229,7 @@
ipp.addAttribute(a);
// ------------
@@ -1315,7 +1315,7 @@
a = new IPPAttribute( IPPDefs.TAG_OPERATION, IPPDefs.TAG_CHARSET,
"attributes-charset" );
ipp.addAttribute(a);
// ------------
@@ -1375,7 +1375,7 @@
a = new IPPAttribute( IPPDefs.TAG_OPERATION, IPPDefs.TAG_CHARSET,
"attributes-charset" );
ipp.addAttribute(a);
Index: scripting/java/src/com/easysw/cups/IPPAttribute.java
--- scripting/java/src/com/easysw/cups/IPPAttribute.java (revision 7178)
+++ scripting/java/src/com/easysw/cups/IPPAttribute.java (working copy)
@@ -7,7 +7,7 @@
These coded instructions, statements, and computer programs are the
@@ -263,7 +263,9 @@
{
IPPValue val;
int bytes = 0; // Start with one for the group tag.
Charset utf8 = Charset::forName("UTF-8");
ByteBuffer temp;
+
//
// Add 1 if first time, or group tag changes.
//
@@ -308,8 +310,12 @@
case IPPDefs.TAG_CHARSET:
case IPPDefs.TAG_LANGUAGE:
case IPPDefs.TAG_MIMETYPE:
break;
case IPPDefs.TAG_DATE :
@@ -329,9 +335,13 @@
case IPPDefs.TAG_TEXTLANG :
case IPPDefs.TAG_NAMELANG :
break;
default :
@@ -359,6 +369,8 @@
int i,j, n;
int bi = 0; // Start with one for the group tag.
byte[] bytes = new byte[sz];
Charset utf8 = Charset::forName("UTF-8");
ByteBuffer temp;
break;
case IPPDefs.TAG_DATE:
@@ -456,23 +472,30 @@
case IPPDefs.TAG_TEXTLANG :
case IPPDefs.TAG_NAMELANG :
- bytes[bi++] = (byte)val.text.charAt(j);
break;
default :