Menu

#1976 degree convert error when used with popen under OSX

None
closed
nobody
None
2017-12-20
2017-10-12
Anonymous
No

I am getting the following error:

line 0: warning: iconv failed to convert degree sign

which seems to come from static void set_degreesign(char locale)
which is in set.c - this I can learn from google -

when executing, in C++ (actually this part is plain vanilla C)

ThePipe = popen("/usr/local/bin/gnuplot --persist","w");

where ThePipe has been declared as FILE*

The warning does not occur when gnuplot --persist is executed as a line command, under /bin/sh or /bin/tcsh.

Version info:

gnuplot is 5.2, patchlevel 0 but this has been happening for several releases now
Mac OS X version 10.12.6 - might have been happening under 10.10, I am only about 80% sure
Xcode version 9.0 and was definitely happening in at least 1 prior release.

Related

Bugs: #1976

Discussion

  • Ethan Merritt

    Ethan Merritt - 2017-10-12

    The error must have something to do with the locale setting. If you open gnuplot via a pipe as you show and then tell it "show locale" and "show decimal", what does it report? Is that the same as it reports when you run it from the command line?

     

    Last edit: Ethan Merritt 2017-10-12
  • Leo Bellantoni

    Leo Bellantoni - 2017-12-15

    Hi Ethan,

    In the pipe, show locale says
    gnuplot LC_CTYPE C
    gnuplot encoding default
    gnuplot LC_TIME C
    gnuplot LC_NUMERIC C
    in a terminal it says
    gnuplot LC_CTYPE en_US.UTF-8
    gnuplot encoding utf8
    gnuplot LC_TIME en_US.UTF-8
    gnuplot LC_NUMERIC C

    The same result occurs in both pipe and terminal for show decimal:
    decimalsign for input is .
    decimalsign for output has default value (normally '.')
    degree sign for output is °

    Thanks for your help!

     
    • Ethan Merritt

      Ethan Merritt - 2017-12-20

      The decimal sign is shown correctly in the output you provide above. Are you seeing that error message even though the character is in fact converted?

      Anyhow, it is clear that the locale inside the pipe is not being set to UTF-8. That is something you would have to change at a system level. I do not know how to do this under OSX. Alternatively you could wrap the gnuplot invocation inside a script that sets the locale first.

       
      • Leo Bellantoni

        Leo Bellantoni - 2017-12-20

        Hi Ethan,

        I’m trying now a

        popen("export LANG='en_US.UTF-8'; /usr/local/bin/gnuplot --persist","w”);

        and mostly it seems to work… I did get one case where it seemed to not work, but could not reproduce it. It looks like popen in OSX makes its /bin/sh with basically no variables at all defined, not even LANG.

        Thanks for you help. I guess for now we could call this solved.

        Yours truly,

        Leo Bellantoni
        Senior Scientist

        Fermi National Accelerator Laboratory
        630 730 2155
        bellanto@fnal.govhttp://person@fnal.gov/

        On Dec 20, 2017, at 3:33 PM, Ethan Merritt sfeam@users.sf.net<mailto:sfeam@users.sf.net> wrote:

        The decimal sign is shown correctly in the output you provide above. Are you seeing that error message even though the character is in fact converted?

        Anyhow, it is clear that the locale inside the pipe is not being set to UTF-8. That is something you would have to change at a system level. I do not know how to do this under OSX. Alternatively you could wrap the gnuplot invocation inside a script that sets the locale first.


        [bugs:#1976]https://sourceforge.net/p/gnuplot/bugs/1976/ degree convert error when used with popen under OSX

        Status: open
        Priority:
        Created: Thu Oct 12, 2017 10:47 PM UTC by Anonymous
        Last Updated: Fri Dec 15, 2017 08:08 PM UTC
        Owner: nobody

        I am getting the following error:

        line 0: warning: iconv failed to convert degree sign

        which seems to come from static void set_degreesign(char locale)
        which is in set.c - this I can learn from google -

        when executing, in C++ (actually this part is plain vanilla C)

        ThePipe = popen("/usr/local/bin/gnuplot --persist","w");

        where ThePipe has been declared as FILE*

        The warning does not occur when gnuplot --persist is executed as a line command, under /bin/sh or /bin/tcsh.

        Version info:

        gnuplot is 5.2, patchlevel 0 but this has been happening for several releases now
        Mac OS X version 10.12.6 - might have been happening under 10.10, I am only about 80% sure
        Xcode version 9.0 and was definitely happening in at least 1 prior release.


        Sent from sourceforge.nethttp://sourceforge.net/ because you indicated interest in https://sourceforge.net/p/gnuplot/bugs/1976/

        To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

         

        Related

        Bugs: #1976

  • Ethan Merritt

    Ethan Merritt - 2017-12-20
    • status: open --> closed
    • Group: -->
    • Priority: -->
     

Log in to post a comment.