What's the most reliable way to determine the current codepage from a shell script?

I want to determine the current environment codepage at runtime from a Unix shell script. What's the safest way to do this?

I am considering the parsing $ LC_ALL environment variable, but it is not always set to a useful value, and its format appears to change (could be <locale> or <locale>. <Code page>, or <locale>. <Code page> @ <modifier> etc.).

Is there a better way? I am essentially after a shell equivalent to what I would get if I called nl_langinfo (CODESET) from C.

+2


a source to share


1 answer


Run:



locale charmap

      

+5


a source







All Articles