Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 399601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:51:44+00:00 2026-05-12T16:51:44+00:00

In linux terminal one would type locale charmap in order to see what kind

  • 0

In linux terminal one would type

locale charmap

in order to see what kind of character-encoding your system uses, eg UTF-8.
My question is how would you do this using c/c++. (I’m using linux)

edit: I tried using

nl_langinfo(CODESET)

but I got ANSI_X3.4-1968 instead of UTF-8 (which is what I get when typing: locale charmap). Am I using nl_langinfo() wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:51:44+00:00Added an answer on May 12, 2026 at 4:51 pm
    SETLOCALE(3)               Linux Programmer’s Manual              SETLOCALE(3)
    
    NAME
           setlocale - set the current locale
    
    SYNOPSIS
           #include <locale.h>
    
           char *setlocale(int category, const char *locale);
    
    DESCRIPTION
           The  setlocale() function is used to set or query the program’s current
           locale.
    

    NL_LANGINFO(3)             Linux Programmer’s Manual            NL_LANGINFO(3)
    
    NAME
           nl_langinfo - query language and locale information
    
    SYNOPSIS
           #include <langinfo.h>
    
           char *nl_langinfo(nl_item item);
    
    DESCRIPTION
           The  nl_langinfo()  function provides access to locale information in a
           more flexible way than localeconv(3) does.  Individual  and  additional
           elements  of  the locale categories can be queried.  setlocale(3) needs
           to be executed with proper arguments before.
           Examples for the locale elements that can be specified  in  item  using
           the constants defined in <langinfo.h> are:
    
           CODESET (LC_CTYPE)
              Return  a string with the name of the character encoding used in
              the  selected  locale,  such  as   "UTF-8",   "ISO-8859-1",   or
              "ANSI_X3.4-1968"  (better  known as US-ASCII).  This is the same
              string that you get with "locale charmap".  For a list of  char‐
              acter encoding names, try "locale -m", cf. locale(1).
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Python program for Linux and the program basically uses the terminal
In a Linux terminal, when the output of one command is too long to
Is there any way under linux/terminal to count, how many times the char f
when compiling some projects on linux terminal, I get usually a long output consisting
I want to implement the command line features like in a linux terminal. I
How do I print coloured characters to a Linux terminal that supports it? How
Want to open firefox from terminal at linux with firebug enabled // Terminal $
I use terminal from Mac OS X Leopard to connect to remote Linux machines
I'm using ssh in Terminal to ssh into a Linux host where I'm running
I am using a interactive command line program in a Linux terminal running the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.