首页 > 其他分享 >[c]: 语言环境设置 -- setlocale()

[c]: 语言环境设置 -- setlocale()

时间:2024-01-18 22:56:58浏览次数:26  
标签:gcc enable setlocale -- options 设置 print Display

[c]:  语言环境设置 -- setlocale()

 

 

 

 

一、语言环境设置【fedora】

 

 

  1、【Linux -- 类redhat 】语言环境设置

 

    1.1、查看语言环境【/etc/locale.conf】:/etc/locale.conf

 

 

  2、【Linux -- 类debian 】语言环境设置

 

    2.1、查看语言环境【/etc/default/locale】:/etc/default/locale

 

 

  3、【gcc    版本信息】

 1 [wit@fedora tmp]$ gcc -v
 2 
 3 Using built-in specs.
 4 
 5 COLLECT_GCC=gcc
 6 
 7 COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper
 8 
 9 OFFLOAD_TARGET_NAMES=nvptx-none
10 
11 OFFLOAD_TARGET_DEFAULT=1
12 
13 Target: x86_64-redhat-linux
14 
15 Configured with: ../configure 
16 
17 --enable-bootstrap 
18 
19 --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto 
20 
21 --prefix=/usr 
22 
23 --mandir=/usr/share/man 
24 
25 --infodir=/usr/share/info 
26 
27 --with-bugurl=http://bugzilla.redhat.com/bugzilla 
28 
29 --enable-shared 
30 
31 --enable-threads=posix 
32 
33 --enable-checking=release 
34 
35 --enable-multilib 
36 
37 --with-system-zlib 
38 
39 --enable-__cxa_atexit 
40 
41 --disable-libunwind-exceptions 
42 
43 --enable-gnu-unique-object
44 
45 --enable-linker-build-id 
46 
47 --with-gcc-major-version-only 
48 
49 --enable-libstdcxx-backtrace 
50 
51 --with-libstdcxx-zoneinfo=/usr/share/zoneinfo 
52 
53 --with-linker-hash-style=gnu 
54 
55 --enable-plugin 
56 
57 --enable-initfini-array 
58 
59 --with-isl=/builddir/build/BUILD/gcc-13.2.1-20231011/obj-x86_64-redhat-linux/isl-install 
60 
61 --enable-offload-targets=nvptx-none 
62 
63 --without-cuda-driver 
64 
65 --enable-offload-defaulted 
66 
67 --enable-gnu-indirect-function 
68 
69 --enable-cet 
70 
71 --with-tune=generic 
72 
73 --with-arch_32=i686 
74 
75 --build=x86_64-redhat-linux 
76 
77 --with-build-config=bootstrap-lto 
78 
79 --enable-link-serialization=1
80 
81 Thread model: posix
82 
83 Supported LTO compression algorithms: zlib zstd
84 
85 gcc version 13.2.1 20231011 (Red Hat 13.2.1-4) (GCC)

 

 

  4、【gcc  帮助信息】

 1 [wit@fedora tmp]$ gcc  --help
 2 Usage: gcc [options] file...
 3 Options:
 4   -pass-exit-codes         Exit with highest error code from a phase.
 5   --help                   Display this information.
 6   --target-help            Display target specific command line options (including assembler and linker options).
 7   --help={common|optimizers|params|target|warnings|[^]{joined|separate|undocumented}}[,...].
 8                            Display specific types of command line options.
 9   (Use '-v --help' to display command line options of sub-processes).
10   --version                Display compiler version information.
11   -dumpspecs               Display all of the built in spec strings.
12   -dumpversion             Display the version of the compiler.
13   -dumpmachine             Display the compiler's target processor.
14   -foffload=<targets>      Specify offloading targets.
15   -print-search-dirs       Display the directories in the compiler's search path.
16   -print-libgcc-file-name  Display the name of the compiler's companion library.
17   -print-file-name=<lib>   Display the full path to library <lib>.
18   -print-prog-name=<prog>  Display the full path to compiler component <prog>.
19   -print-multiarch         Display the target's normalized GNU triplet, used as
20                            a component in the library path.
21   -print-multi-directory   Display the root directory for versions of libgcc.
22   -print-multi-lib         Display the mapping between command line options and
23                            multiple library search directories.
24   -print-multi-os-directory Display the relative path to OS libraries.
25   -print-sysroot           Display the target libraries directory.
26   -print-sysroot-headers-suffix Display the sysroot suffix used to find headers.
27   -Wa,<options>            Pass comma-separated <options> on to the assembler.
28   -Wp,<options>            Pass comma-separated <options> on to the preprocessor.
29   -Wl,<options>            Pass comma-separated <options> on to the linker.
30   -Xassembler <arg>        Pass <arg> on to the assembler.
31   -Xpreprocessor <arg>     Pass <arg> on to the preprocessor.
32   -Xlinker <arg>           Pass <arg> on to the linker.
33   -save-temps              Do not delete intermediate files.
34   -save-temps=<arg>        Do not delete intermediate files.
35   -no-canonical-prefixes   Do not canonicalize paths when building relative
36                            prefixes to other gcc components.
37   -pipe                    Use pipes rather than intermediate files.
38   -time                    Time the execution of each subprocess.
39   -specs=<file>            Override built-in specs with the contents of <file>.
40   -std=<standard>          Assume that the input sources are for <standard>.
41   --sysroot=<directory>    Use <directory> as the root directory for headers
42                            and libraries.
43   -B <directory>           Add <directory> to the compiler's search paths.
44   -v                       Display the programs invoked by the compiler.
45   -###                     Like -v but options quoted and commands not executed.
46   -E                       Preprocess only; do not compile, assemble or link.
47   -S                       Compile only; do not assemble or link.
48   -c                       Compile and assemble, but do not link.
49   -o <file>                Place the output into <file>.
50   -pie                     Create a dynamically linked position independent
51                            executable.
52   -shared                  Create a shared library.
53   -x <language>            Specify the language of the following input files.
54                            Permissible languages include: c c++ assembler none
55                            'none' means revert to the default behavior of
56                            guessing the language based on the file's extension.
57 
58 Options starting with -g, -f, -m, -O, -W, or --param are automatically
59  passed on to the various sub-processes invoked by gcc.  In order to pass
60  other options on to these processes the -W<letter> options must be used.
61 
62 For bug reporting instructions, please see:
63 <http://bugzilla.redhat.com/bugzilla>.
64 [wit@fedora tmp]$ 
65 [wit@fedora tmp]$ 

 

 

 

二、源代码

 1 [wit@fedora tmp]$ cat  locale.c 
 2 #include <locale.h>
 3 #include <stdio.h>
 4 #include <time.h>
 5  
 6 int main ()
 7 {
 8    time_t currtime;
 9    struct tm *timer;
10    char buffer[80];
11  
12    time( &currtime );
13    timer = localtime( &currtime );
14  
15    printf("Locale is: %s\n", setlocale(LC_ALL, "en_GB.UTF-8"));
16    strftime(buffer,80,"%c", timer );
17    printf("Date is: %s\n", buffer);
18  
19   
20    printf("Locale is: %s\n", setlocale(LC_ALL, "zh_CN.UTF-8"));
21    strftime(buffer,80,"%c", timer );
22    printf("Date is: %s\n", buffer);
23  
24    return(0);
25 }

 

 

 

三、运行结果

1 [wit@fedora tmp]$ gcc -g -Wall -std=c2x -o locale locale.c && ./locale
2 Locale is: en_GB.UTF-8
3 Date is: Thu 18 Jan 2024 22:50:30 CST
4 Locale is: zh_CN.UTF-8
5 Date is: 2024年01月18日 星期四 22时50分30秒
6 [wit@fedora tmp]$ 
7 [wit@fedora tmp]$ 

 

 

 

四、参考资料

 

  1、  C 库函数 - setlocale()  --  https://www.runoob.com/cprogramming/c-function-setlocale.html

 

标签:gcc,enable,setlocale,--,options,设置,print,Display
From: https://www.cnblogs.com/lnlidawei/p/17973598

相关文章

  • 线性代数
    线性相关若有\(\mathbb{a}=\{a_1,a_2,\dots,a_n\}\),且\(x\mathbb{a}=0\),那么这组向量线性相关。大致可以理解成有一些无用的方程。一组可以表示原来所有线性组合的向量叫做一组基。如果值域只有\(0/1\),那这就是异或线性基。否则,上高消就可以搞出一组这样的基。异或线性基......
  • Git(千锋)
    目录Git一.走入Git1.Git介绍2.Git对比SVN3.Git安装二.Git常用命令1.设置用户签名2.初始化本地库3.Git工作区、暂存区和版本库4.gitadd5.gitcommit6.gitrevert与gitreset三.Git分支1.初识分支2.创建分支3.切换分支4.合并分支5.删除分支四.远程仓库1.创建一个远程仓库2.添......
  • 【驱动】I2C驱动分析(一)-I2C驱协议简介
    什么是I²CI²C叫集成电路总线它是一种串行通信接口,具有双向两线同步串行总线,通常由两根线组成——SDA(串行数据线)和SCL(串行时钟线)和上拉电阻。它们用于需要许多不同部件(例如传感器、引脚、扩展和驱动程序)协同工作的项目,因为它们可以将多达128个设备连接到主板,同时保持清晰......
  • 寒训1.11记录
    AtCoderBeginnerContest272-AtCoderA-IntegerSum(赛题目概述求和B-EveryoneisFriends(赛题目概述二维数组记录相互关系即可,数据量少可用\(O(n^3)\)C-MaxEven(赛题目概述从非负整数数列中找出和为偶数,且和最大的两个数解题思路遍历数列,把偶数和奇数放入两个向......
  • 质数判断&质因数分解
    引入众所周知,素数的判断在longlong级别是不能\(O(\sqrt{n})\)硬上的。那怎么办呢??参考文献。ababab,先来最低效的。以下复杂度均考虑高精。1.试除法\(O(\sqrtn)\)枚举,\(n\le10^{14}\)。优化只枚举质数,无法优化预处理质数时间。2.Millar-Rabinlonglong:\(O(k\t......
  • 16 Battling with Numbers
    组合数(2次方级)的组合#include<bits/stdc++.h>#defineintlonglongusingnamespacestd;constintmod=998244353;voidsolve(){ intn; cin>>n; vector<int>a(n+1); for(inti=1;i<=n;i++)cin>>a[i]; map<int,int>mp; for(inti=1;i&l......
  • 17 Two-Colored Dominoes
    多米诺骨牌在棋盘上放置多米诺骨牌,两端的颜色都不一样,要求横竖的总和是一样的......
  • 初中英语优秀范文100篇-062Going to Sleep Early Is a Good Habit早一点睡觉是个好习
    PDF格式公众号回复关键字:SHCZFW062记忆树1Goingtosleepearlyisofgreatbenefittome.翻译早一点睡觉对我非常有益。简化记忆早睡句子结构"Goingtosleepearly"是主语,表示一个动作或状态。"is"是系动词,用来连接主语和表语,表示主语的特征或状态。"ofgreat......
  • Web安全-SQL注入常用函数(二)
    ★★实战前置声明★★文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与学习之用,读者将其信息做其他用途,由用户承担全部法律及连带责任,文章作者不承担任何法律及连带责任。1、MySQL数据库构成初始化安装MySQL数据库后(基于MySQL版本5.7.x),默认会创建4个系统数据库:#默认......
  • CodeForces & AtCoder rating 规则简述
    译者:rui_er,转载请注明出处。(备份自2020年11月2日的同名博客)本博客为了方便自己查阅,同时也方便大家了解,但因为我英语很菜,所以难免有翻译错的地方,还请评论区纠正。未注明资料来源的均为常识积累。1CodeForcesrating规则1.1CodeForcesrating与名字颜色换算设\(r\)......