How to obtain the default encoding of system?

a script run on linux or windows, i want to know the encoding of system,
in
order to ouput suitable string.thanks