LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 01-22-2020, 10:30 PM   #1
tinkerbeast
LQ Newbie
 
Registered: Jan 2020
Posts: 1

Rep: Reputation: Disabled
What is the execution charset with which Linux is compiled?


I know that the -fexec-charset=charset flag for compiled Linux systems will probably be the default UTF-8. My question is: How do I verify that? Is there some /proc variable which will tell me that?

The rationale behind my question is that system calls which take char * as a parameter expect the encoding to be in the same format as the compiled kernel. The safest way would be to use the kernel provided variable as a parameter for compiling an application doing system calls.

Note that this is independent of the system locale.

Added sample program to illustrate the isssue:

Code:
const char * file_name = "/tmp/有難う.txt";

int main(void) {
    if (open(file_name, 0) < 0) {
        perror("failed to open file");
    } else {
        perror("opened file");
    }
    return 0;
}
Code:
$ touch /tmp/有難う.txt
$ gcc -fexec-charset=UTF-8 source.c && ./a.out
opened file: Success
$ gcc -fexec-charset=UTF-16 source.c && ./a.out
��f: No such file or directory
 
Old 02-05-2020, 05:18 PM   #2
elucches
Member
 
Registered: Jan 2011
Posts: 108

Rep: Reputation: 11
I believe
Code:
man nl_langinfo
may give you the answer.
Briefly:
Code:
#include <langinfo.h>
#include <locale.h>
...
   setlocale(LC_CTYPE, "");
   printf("%s\n", nl_langinfo(CODESET));
I guess in your case it would not be printf but saving into a variable.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Unknown symbol __fentry__ (err 0)" - loading compiled module on compiled kernel 3.18 Jason_25 Linux - Kernel 1 12-25-2014 05:45 AM
Compiled program not showing up as compiled and not able to run. hjoshuaj Linux - Newbie 3 03-27-2014 05:49 AM
are they same " sh execution " and " ./ execution " shravee Linux - Newbie 1 04-17-2010 01:11 AM
Execution of PERL scripts in Linux which is compiled in WINDOWs environment to_veera Linux - Software 3 06-18-2004 08:50 AM
HOw to add a special charset support to Red Hat Linux? George2 Linux - Software 6 12-13-2003 06:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 05:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration