ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: Dmitry Vukolov <dvukol@rosmail.ru>
To: community@altlinux.ru
Cc: Юрий <rud_ras@tut.by>
Subject: Re: [Comm] Color HPLaserJet 4550+hpoj
Date: Mon, 12 Apr 2004 07:53:05 +0400
Message-ID: <200404120753.19027.dvukol@rosmail.ru> (raw)
In-Reply-To: <20040407175925.0417cdc7.rud_ras@tut.by>


[-- Attachment #1.1: Type: text/plain, Size: 672 bytes --]

On Wednesday 07 April 2004 18:59, Юрий wrote:
> On Wed, 7 Apr 2004 18:33:16 +0400
>
> Dmitry Vukolov <dvukol@rosmail.ru> wrote:
> > On Tuesday 06 April 2004 20:59, Юрий wrote:
<skipped>
> > > вдогонку
> > >
> > > $ ptal-hp hpjd:192.168.1.3 display
> > > POWERSAVE ╡╨╩.
> > >
> > > тоже по русски не показывает :-(
> >
> > $ echo POWERSAVE ╡╨╩. | iconv -f iso8859-5 -t koi8-r
> > POWERSAVE ВКЛ.
> >
> > Можно сваять патчик. Я гляну.
>
> Спасибо, было бы не плохо.

Юрий, будьте добры, проверьте xojpanel с приложенным патчем. У меня, к 
сожалению, нет русскоговорящих принтеров :-)
Если всё будет нормально, то на днях выложу новую сборку hpoj в Сизиф.

-- 
Dmitry Vukolov

[-- Attachment #1.2: hpoj-0.91-alt-xojpanel-enc.patch --]
[-- Type: text/x-diff, Size: 4969 bytes --]

diff -Nur hpoj-0.91.orig/apps/xojpanel/xojpanel.cpp hpoj-0.91/apps/xojpanel/xojpanel.cpp
--- hpoj-0.91.orig/apps/xojpanel/xojpanel.cpp	2002-07-25 13:01:24 +0400
+++ hpoj-0.91/apps/xojpanel/xojpanel.cpp	2004-04-10 21:53:36 +0400
@@ -56,6 +56,7 @@
 #include <qlabel.h>
 #include <qpixmap.h>
 #include <qstring.h>
+#include <qtextcodec.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
@@ -96,6 +97,10 @@
 // Prints the contents of the character map to stdout.
 // #define DISPLAY_CHARACTER_MAP
 //
+// Default encoding used by device for LCD messages
+//#define DEFAULT_DEVICE_ENCODING "ISO8859-1"
+#define DEFAULT_DEVICE_ENCODING "ISO8859-5"
+//
 // In a case where you are using KDE2 and you built xojpanel
 // with qt-2.0.x, you may see a message like this:
 // "XError: BadValue(...)2". If so, try uncommenting the next line.
@@ -127,6 +132,7 @@
 	caption = "";
 	useCaption = false;
 	ptalDeviceName = "";
+	deviceEncoding = DEFAULT_DEVICE_ENCODING;
 	bool deviceNameInTitle = true;
 	bool displayHelp = false;
 	bool isTranslationEnabled = true;
@@ -157,6 +163,11 @@
 			useCaption = true;
 			i++;		
 		}
+	    
+		else if(qstrcmp(argv[i], "-devenc") == 0) {
+			deviceEncoding = argv[i+1];
+			i++;		
+		}
 		
 		else if( (!possibleDeviceNameFound) && argv[i][0] != '-' ) {
 			// Assume first unidentified argument is ptalDeviceName
@@ -188,14 +199,16 @@
 			"\nOptions:\n\n"
 			
 
-			"\t-help\t\tPrint this information and exit.\n"
+			"\t-help\t\t\tPrint this information and exit.\n"
+
+			"\t-caption <text>\t\tOptional text to be displayed in titlebar.\n"
 
-			"\t-caption <text> Optional text to be displayed in titlebar.\n"
+			"\t-notrans\t\tDisables 'special character' translation.\n"
 
-			"\t-notrans\tDisables 'special character' translation.\n"
+			"\t-devenc <encoding>\tEncoding used by device for LCD messages.\n"
 
-			"\t-hidedevname\tPrevents PTAL device name from\n"
-			"\t\t\tbeing displayed in the titlebar.\n\n"
+			"\t-hidedevname\t\tPrevents PTAL device name from\n"
+			"\t\t\t\tbeing displayed in the titlebar.\n\n"
 
 			"\tThe first option *not* prefixed with a dash ('-')\n"
 			"\twill be be used as the PTAL device name. If a default\n"
@@ -317,6 +330,7 @@
 		characterMap[0x11] = 0xbb; // Right arrow to '>>'
 		characterMap[0x12] = 0xa3; // Large pound(?) to small pound
 		characterMap[0x13] = 0xbb; // Right hollow triangle to '>>'
+		characterMap[0x15] = 0xbb; // Right hollow triangle to '>>'
 		characterMap[0x80] = 0xab; // Left hollow triangle to '<<'
 		characterMap[0x81] = 0xbb; // Right black triangle to '>>'
 		characterMap[0x82] = 0x2a; // Hollow circle to '*'
@@ -529,8 +543,10 @@
 
 	int length = strlen(string);
 	int i = 0;
-	int spaces = 0;
+	int encFrom = 0;
+	unsigned int spaces = 0;
 	QString tmpString;
+	QTextCodec *codec;
 
 	#ifdef SHOW_LCD_MESSAGE_ASCII_CODES
 		// Show contents of original string as sent from device.
@@ -546,28 +562,40 @@
 		if ( string[0] != 0 ) printf("\nNew message:\n");
 	#endif
 
+	// Initialize the codec
+	codec = QTextCodec::codecForName(deviceEncoding);
+	if ( ! codec )
+	    codec = QTextCodec::codecForName(DEFAULT_DEVICE_ENCODING);
+	
 	// Convert each character in string[] to corresponding
-	// character in characterTranslationMap[]
-	for ( int i = 0; i < length; i++ ) {
-		string[i] = characterTranslationMap[ (unsigned char)string[i] ];
+	// character in characterTranslationMap[] and apply necessary encoding
+	// conversion
+	for ( i = 0; i < length; i++ ) {
+	    if ((char)characterTranslationMap[ (unsigned char)string[i] ]
+	            != string[i]) {
+	        tmpString += codec->toUnicode(string + encFrom, i - encFrom);
+	        tmpString += 
+	            QChar(characterTranslationMap[ (unsigned char)string[i] ]);
+	        encFrom = i + 1;
+	    }
 	}
+	tmpString += codec->toUnicode(string + encFrom, i - encFrom);
 
 	spaces = 0;
-	i = length - 1 ;
+	i = tmpString.length() - 1 ;
 
 	// Count spaces on the trailing end of the string.
-	while( string[i] == 0x20 ) {
+	while( tmpString[i] == 0x20 ) {
 		// printf("i is now= %d\n", i);
 		spaces++;
 		// printf("spaces= %d\n\n", spaces);
 
 		// Don't cycle through again if the entire string
 		// is counted for removal. It could result in a segfault.
-		if( spaces >= length ) break;
+		if( spaces >= tmpString.length() ) break;
 		i--;
 	}
 
-	tmpString = string;
 	// printf("tmpString= %s\n",(const char*)tmpString );
 
 	// Remove trailing spaces and assign text to appropriate message line.
diff -Nur hpoj-0.91.orig/apps/xojpanel/xojpanel.h hpoj-0.91/apps/xojpanel/xojpanel.h
--- hpoj-0.91.orig/apps/xojpanel/xojpanel.h	2002-07-25 13:01:24 +0400
+++ hpoj-0.91/apps/xojpanel/xojpanel.h	2004-04-10 20:35:01 +0400
@@ -83,6 +83,7 @@
 
 	char* caption;
 	char* ptalDeviceName;
+	char* deviceEncoding;
  	
 	bool useCaption;
 	

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2004-04-12  3:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-06 15:34 Юрий
2004-04-06 16:59 ` Юрий
2004-04-07 14:33   ` Dmitry Vukolov
2004-04-07 14:59     ` Юрий
2004-04-12  3:53       ` Dmitry Vukolov [this message]
2004-04-15 13:35           ` Dmitry Vukolov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200404120753.19027.dvukol@rosmail.ru \
    --to=dvukol@rosmail.ru \
    --cc=community@altlinux.ru \
    --cc=rud_ras@tut.by \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git