|
From: Ethan M. <merritt@u.washington.edu> - 2007-08-01 22:48:29
|
On Wednesday 01 August 2007 00:40, Shigeharu TAKENO wrote:
>
> In Japanese environment, to print the correct Japanese strings
> in the pdf file by the cairopdf terminal, we may need to set the
> environment variable CHARSET to the corresponding value of the
> script encoding, especially in the case 'gnuplot script_file'.
> In this case we cannot get the correct output even if the script
> file is UTF-8 encoding and LANG=ja_JP.UTF-8.
This seems to be an actual bug. We should try to fix the bug first,
and then afterwards we can see if we still need to document a
work-around.
On my linux systems, the Japanese + cairopdf problem can be
solved by adding a call to
setlocale(LC_CTYPE,"");
on program entry. That may or may not be an acceptable change, however.
Perhaps it would be better to make this part of the "set encoding"
command. For terminals such as cairopdf it would be sufficient
to add an option
set encoding locale
without actually adding to the internal table of known encodings.
I append a patch below that implements this.
For some other terminals we might have to also add explicit known
encoding labels.
For reference, the current list is
gnuplot> help set encoding
Valid values are
default - tells a terminal to use its default encoding
iso_8859_1 - the jmost common Western European font used by many
Unix workstations and by MS-Windows. This encoding is
known in the PostScript world as 'ISO-Latin1'.
iso_8859_2 - used in Central and Eastern Europe
iso_8859_15 - a variant of iso_8859_1 that includes the Euro symbol
koi8r - popular Unix cyrillic encoding
koi8u - ukrainian Unix cyrillic encoding
cp437 - codepage for MS-DOS
cp850 - codepage for OS/2, Western Europe
cp852 - codepage for OS/2, Central and Eastern Europe
cp1250 - codepage for MS Windows, Central and Eastern Europe
I was already planning to add utf8 (needed for png terminal + Adobe
symbol font, and for PostScript using patchset #1746352).
Perhaps we also should have some or all of
EUC-JP shift-jis ujis iso_2022_jp
But I really don't know how to support these for most terminal types.
The following patch implements "set encoding locale"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--- gnuplot/src/set.c 2007-06-22 01:05:19.000000000 -0700
+++ gnuplot-cvs/src/set.c 2007-08-01 15:37:07.000000000 -0700
@@ -1217,7 +1217,11 @@
if(END_OF_COMMAND)
temp = S_ENC_DEFAULT;
- else {
+ else if (equals(c_token,"locale")) {
+ c_token++;
+ setlocale(LC_CTYPE,"");
+ return;
+ } else {
temp = lookup_table(&set_encoding_tbl[0],c_token);
if (temp == S_ENC_INVALID)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ethan
>
> I propose to add the following explanation to cairopdf terminal
> help, which is unified diff to
>
> $Id: cairo.trm,v 1.2 2007/07/20 19:12:50 tlecomte Exp $
>
> ----- From here -----
> --- cairo.trm.ORG 2007-07-21 04:12:50.000000000 +0900
> +++ cairo.trm 2007-08-01 16:28:08.000000000 +0900
> @@ -687,6 +687,16 @@
> " OpenOffice Symbol fonts, and remove the Microsoft one.",
> " Other non-conform fonts, such as \"wingdings\" have been observed working.",
> "",
> +" If you use another encoding which is not supported by `set encoding`",
> +" (ex. using the title string in Japanese), you may need to set the",
> +" environment variable CHARSET for your glib, especially in case you give",
> +" the script file as the form \'gnuplot script_file\'. In the case, you",
> +" can solve the problem by setting the environment variable CHARSET as",
> +" the corresponding value to the script encoding. For example, if the",
> +" script is Japanese EUC encoding (EUC-JP), you should set CHARSET to",
> +" \"EUC-JP\", if UTF-8 encoding, set CHARSET to \"UTF-8\", and if",
> +" Shift_JIS encoding, set CHARSET to \"SHIFT_JIS\".",
> +"",
> " The rendering of the plot cannot be altered yet. To obtain the best output",
> " possible, the rendering involves two mechanisms : antialiasing and",
> " oversampling.",
> ----- To here -----
>
> +========================================================+
> Shigeharu TAKENO NIigata Institute of Technology
> kashiwazaki,Niigata 945-1195 JAPAN
> sh...@ie... TEL(&FAX): +81-257-22-8161
> +========================================================+
--
Ethan A Merritt
|