What is the most robust way of determining the current codepage from a shell script?

Posted by rewbs on Stack Overflow See other posts from Stack Overflow or by rewbs
Published on 2010-05-14T18:01:21Z Indexed on 2010/05/14 18:04 UTC
Read the original article Hit count: 172

Filed under:
|
|
|
|

Hi all,

I'd like to determine the environment's current codepage at runtime from a Unix shell script. What's the most reliable way of doing this?

I'm looking into parsing environment variable $LC_ALL, but it isn't always set to a useful value, and its format seems to vary (can be <locale>, or <locale>.<code page>, or <locale>.<code page>@<modifier> etc...).

Is there a better way? I'm essentially after a shell equivalent of what I'd get if I called nl_langinfo(CODESET) from C.

© Stack Overflow or respective owner

Related posts about shell

Related posts about bash