Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] CJK Printing from Web Browsers in Debian 3.3.2



On 04/11/06, Bart Mathias <mathias@example.com> wrote:

I went ahead and ran the suggested commands without studying their man
pages; I prefer to know what I'm doing, but these look like a long
study.  I've never really understood how "Abracadabra" works either.

Nah, they're pretty straight-forward. ;)

When they didn't work--Thunderbird printed squares on a test--and the
Firefox and Mozilla prefs still looked fairly different when I opened them
side by side (Mozilla still prints Japanese OK), I shut all Mozilla
stuff down again and ran just the

sed -i.bak -e 's|^\(.\+intl.\+\)$|// \1|'
.mozilla/firefox/ucf0ouei.default/prefs.js

command again, and took another look at the file.  It reported a
last-modified time the same as when I ran the command, but nothing in
the file looks commented out.

Odd. Obviously I have an error in the sed expression somewhere. Even though I tested it... WTF?

Oh yeah, I figured it out. My Firefox config file did not have any
"print" settings, so I changed the string to "intl" for testing
purposes (never give instructions on a mailing list without testing
them, or Murphy[1]'ll have yer bollucks for breakfast!), and forgot to
change it back.

Try this instead:

sed -i.bak -e 's|^\(.\+print.\+\)$|// \1|'
.mozilla/firefox/ucf0ouei.default/prefs.js

And then the rest of the stuff as I have it.

So I went "man sed" after all, and now I
understand everything in that command except the minor
's|^\(.\+intl.\+\)$|// \1|' part.

That is the same as saying: 's/^\(.\+intl.\+\)$/\/\/ \1/', if that helps any. If it doesn't, what that line does is as follows:

1. The single quotes prevent the shell from trying to interpret the expression.
2. The "s" at the beginning of the expression tells sed to expect a
substitution.
3. The "|" starts the match part of the substitution regex. Like I
said, I could have used a "/" instead, but then I would have had to
escape the literal "//" later in the expression--a sickness known as
Leaning Toothpick Syndrome[1] in The Biz.
4. The "^" character matches the beginning of a line--it is known as
an "anchor" in regex parlance.[2]
5. The "\(" starts a grouping, which sed(1) will remember.
6. The "." matches one of any character (except End-Of-Line--EOL).
7. The "\+" means: match *one* or more of the previous thing; taken
together with (6), it means: match one of more of anything.
8. The "intl" is a literal, and means: match the characters "intl", in
that order.
9. The ".\+" you should now recognise from (6) and (7).
10. The "\)" closes the grouping started in (5).
11. The "$" matches the EOL (End-Of-Line) character, which on Unix is
'\n', and on Windows (and maybe Mac?) is "\r\n".
12. The "|" ends the match portion of the substitution expression. So
far, we have instructed sed thusly: match all characters in any line
containing the literal string "intl", and remember everything between
the beginning and end of the line. The stuff coming after the "|"
character that we just wrote and the next one is what to replace that
with.
13. "// " is a literal string.
14. "\1" is a backreference, which refers the the first group matched
(and saved) in the match portion of the expression. In this case, the
entire line containing the string "intl".
15. The last "|" terminates the expression and tells sed to do its worst.

The result of all of this is that sed should transform lines like:

user_pref("intl.charset.default", "UTF-8");
user_pref("intl.charset.detector", "ja_parallel_state_machine");
user_pref("intl.charsetmenu.browser.cache", "ISO-8859-1, UTF-8,
Shift_JIS, us-ascii, EUC-JP");

into:

// user_pref("intl.charset.default", "UTF-8");
// user_pref("intl.charset.detector", "ja_parallel_state_machine");
// user_pref("intl.charsetmenu.browser.cache", "ISO-8859-1, UTF-8,
Shift_JIS, us-ascii, EUC-JP");

Then I tried setting up a user.js file in Thunderbird, copying in all of
the "...print..." lines from Mozilla's prefs file, hoping it would override
Thunderbird's prefs, but that didn't work either.

Yeah, if you want to do it by hand, you need to comment out all lines containing "print" by placing a "//" at the beginning of the line, *then* add your settings from Mozilla.

> BTW, the kprinter trick will only work if you use KDE (or have it
> installed) and KDE apps print Japanese correctly. Otherwise, just use
>  plain ol' lpr.

I do use KDE.  A couple of years ago I was having some kind of trouble
printing which regularly changing "lpr ${<whatever>}" to just "kprinter"
cured, but I don't remember details (those last four words have become
the story of my life).

kprinter adds a little special sauce of its own to the CUPS o' steaming shite that is printing.

Thanks for trying. Computers is weird.

Yeah, now I'm *re*-trying. Lemme know how it goes.

Cheers,
Josh

[1] http://en.wikipedia.org/wiki/Murphy's_Law
[2] http://en.wikipedia.org/wiki/Leaning_toothpick_syndrome
[3] http://en.wikipedia.org/wiki/Regular_expressions


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links