Menu

#2404 set encoding [string variable]

None
closed
nobody
None
2021-02-04
2021-01-27
No

In git version, some demos are inseted the followin codes:

save_encoding = GPVAL_ENCODING
set encoding utf8
...
reset
set encoding save_encoding

However, it may make error (git version at 2021-01-26 on FreeBSD):

cd demo
../src/gnuplot complex_airy.dem

set encoding save_encoding
^
"complex_airy.dem" line 74: unrecognized encoding specification; see 'help encoding'.

By printf debugging, I see that on the following line of src/set.c (set_encoding()):

/* allow string variables as parameter */
if ((temp == S_ENC_INVALID) && isstringvalue(c_token) && (senc = try_to_get_string())) {

isstringvalue(c_token) seems to be 0 because the udv_value.type == NOTDEFINED, so the try_to_get_string() will not be done. I don't know why the type is NOTDEFINED.

Discussion

  • Bastian Märkisch

    This is weird. Unfortunately, I cannot reproduce this on Windows.
    The mechanism in the demos is not new by the way. I just added it to some more of the newer demos. It only matters if the default encoding on your platform is different from utf8, like e.g. on Windows. After you start gnuplot, what is the result of the following commands?

    show encoding
    print GPVAL_encoding
    

    (Just to be sure: can you also try a "make clean" and rebuild?)

     
  • Ethan Merritt

    Ethan Merritt - 2021-01-27

    It has broken for me also. The "save encoding at start and restore at end" strategy doesn't work when there is a "reset session" command in between. On the other hand, the reset session itself restores the original encoding, so I think the save/set/restore sequence isn't needed anyhow.

    I have reverted the change to the demo for now because it breaks my automated testing sequence.

     
  • Shigeharu TAKENO

    Thanks. I understand. For example,

    s = "Arial,20"
    set title "test" font s
    plot x
    

    works correctly, but,

    s = "Arial,20"
    reset session
    set title "test" font s
    plot x
    

    makes a error:

    gnuplot> set title "hoge" font s
                                                                                                     ^
                               "test.gp" line 4: 'fontname,fontsize' expected
    

    "reset session" may break variables.

     
  • Ethan Merritt

    Ethan Merritt - 2021-02-04
    • status: open --> closed
    • Group: -->
    • Priority: -->
     

Log in to post a comment.

MongoDB Logo MongoDB