Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve bad locale error message, almost always due to absence of setlocale() #414

Closed
allan-simon opened this issue Mar 21, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@allan-simon
Copy link

my program is very simple

#include <notcurses/notcurses.h>

int main(void) {
    struct notcurses* n = notcurses_init(NULL, stdout);

    notcurses_stop(n);
}

however when I execute it, it output a warning (even though I execute explicitly with the LC_ALL variable set):

asimon[21:23] >> LC_ALL=en_US.UTF-8 ./a.out
Term: 104x54 xterm-256color (xterm with 256 colors)

 notcurses 1.2.3 by nick black et al
  54 rows, 104 columns (87.75KiB), 256 colors (direct)
  compiled with gcc-9.2.1 20191008
  terminfo from ncurses 6.1.20190803
  avformat 58.20.100
  avutil 56.22.100
  swscale 5.3.100

 Warning! Encoding is not UTF-8.
@allan-simon
Copy link
Author

my bad after reading more the documentation I've found that setting

 setlocale(LC_ALL, "");

solves the warning

@dankamongmen
Copy link
Owner

I should probably improve that error message. You won't be the last person to run into this problem. Thanks for the report and reminding me to improve this. Reopening.

@dankamongmen dankamongmen reopened this Mar 22, 2020
@dankamongmen dankamongmen self-assigned this Mar 22, 2020
@dankamongmen dankamongmen added the enhancement New feature or request label Mar 22, 2020
@dankamongmen dankamongmen added this to the 1.3.0 milestone Mar 22, 2020
@dankamongmen dankamongmen changed the title LC_ALL and LANG are set to en_US.UTF-8 , but notcurses 1.2.3 still print warning Improve bad locale error message, almost always due to absence of setlocale() Mar 22, 2020
@dankamongmen
Copy link
Owner

[killermike](1) $ export LANG=en_GB 
[killermike](0) $ ./notcurses-demo 
Encoding ("ISO-8859-1") was neither ANSI_X3.4-1968 nor UTF-8, refusing to start
 Did you call setlocale()?
[killermike](1) $ 

I think that will probably come in handy more than once. Thanks for the report @allan-simon , and your interest in Notcurses! This will be present in 1.2.4 if there is a 1.2.4 release, and either way it will be in 1.3.0.

@allan-simon
Copy link
Author

ah thanks yes like this I would have discovered earlier my mistake :)
thanks for your library, i'm currently exploring it to create a little rogue-like game , and it seems much more "sane" than ncurses API.

@dankamongmen
Copy link
Owner

ah thanks yes like this I would have discovered earlier my mistake :)
thanks for your library, i'm currently exploring it to create a little rogue-like game , and it seems much more "sane" than ncurses API.

wonderful! i only beat nethack two years ago, after playing it off-and-on for nearly twenty years :). please don't hesitate to report other places where notcurses could be friendlier. i am accustomed to a good deal of frustration when programming with NCURSES, and hope to eliminate whatever pain points i can :D 🗡️ .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants