title: What is the difference between locale and Encoding ( Terminal )
body: <p>I have tried a few ways to set the terminal 'encoding' from a c++ program.
  All I could do is to change the locale. or the LANG variable.</p>
  
  <p>Still I am able to enter characters which are of different encoding than the LANG ( and output of nl_langinfo(CODESET) )</p>
  
  <p>But , if I go to Terminal > Set Character Encoding > ISO-8859-15 ( or something ) then it is allowing only ISO-8859-15 .
  Can I achive the same thing ( setting from GUI ) from my C++ program as well ?</p>
  
  <p>I used setlocale(LC_CTYPE,"") to set the encoding to the terminal encoding , but it just uses the LANG variable.And allows other characters too.</p>
  
  <p>( After Terminal > Set Character Encoding > ISO-8859-1 ( Latin1 ) )</p>
  
  <pre><code>&gt;setenv LANG en_US.iso885915 --&gt; latin9
  &gt;./a.out 
  Current Locale : C
  Lang info : ANSI_X3.4-1968
  Trying to change locale from C to ""
  Current Locale : en_US.iso885915 
  Lang info : ISO-8859-15
  Enter some string :¤¦¨´¸¼½¾ dfsafas  --&gt; but these are Latin1 charaters !!
  Entered string : ¤¦¨´¸¼½¾ dfsafas --&gt; They are even printed back !!
  </code></pre>
  
  <p>So , this brought me down to the question if my understanding about the locale and encoding are correct or not.</p>
  
  <p>Can someone please clarify the difference?</p>