Home > Back-end >  Linux under the setlocale (LC_ALL, "zh_CN. GBK") set up to fail
Linux under the setlocale (LC_ALL, "zh_CN. GBK") set up to fail

Time:01-03

Under Linux can only set utf-8, seems to be able to set GBK?
Linux coding environment how to modify?
The locale - is a list of all supported set?

CodePudding user response:

Is
Cannot be changed to GBK
Is

I all the answer above is a shot in the dark,

CodePudding user response:

You seem to be some misunderstanding, the function of the function that you want to set to set what you,
In fact, is not the case,
This function set is actually a programmer expectations of this program to run the environment of the local character set in the future,
That is to say, if you expect after you compile the code to run on Windows 7 8 of 10, then you can't write,
This, of course, need the support of the compiler and library systems, with a lot of cross compiler configuration, you can just compiled on Linux link. Exe,

So, if your code to run on your machine to carry out a compilation, you look at the environment variable LANG is what, you can set it to what, what better way is between two double quotes doesn't knock,

CodePudding user response:

BTW, to success in this setting is complete, then use w system library functions, they don't use printf puts these functions, because they will be mischievous,

CodePudding user response:

LANG=zh_CN. GB2312

CodePudding user response:

When think of tea, the operating system this stuff, only when it is the source code, the kernel programmers have qualified to lift it,

Once it's up and running, although now it is not intelligent, but it has its own rules, I write the application of apes can only work in its regulations under the framework of the occasional request it do me a favor,
In its place an acre of three points, it is heaven,

Fortunately, we live outside the system, not great can give it power, formatting, reshipment,

CodePudding user response:

TO: forever74 upstairs and incisive, praise a,
By the way, could you show me my Fedora 33:

CodePudding user response:

refer TO 6th floor ctrigger response:
, forever74 upstairs and incisive, praise a,
By the way, could you show me my Fedora 33:

Why do you support GBK code, I only utf-8 zh_CN?

CodePudding user response:

reference 1/f, zhao teacher reply:
is
Cannot be changed to GBK
Is

I all the answer above is a shot in the dark,

Coding environment that, I mean that, the result of the locale command listed. Is there a way to make it into a zh_CN GBK?

CodePudding user response:

reference 4 floor ctrigger response:
LANG=zh_CN. GB2312

This is set in a configuration file or setlocale Settings? GB2312, GBK, I tried GB18030 setlocale (), is a failure

CodePudding user response:

As may be installed support for Chinese, search

CodePudding user response:

The Linux kernel using UTF - 32, the API layer use utf-8, does not support UTF - 16 and MBCS (unless the application code), in Linux wide character would be UTF - 32 code, with Windows of utf-8 16 different

CodePudding user response:

Sudo apt - get - y install language pack - useful - Hans

CodePudding user response:

Well, I'm sorry I didn't say clear,
Setlocale function can set what depends on which is installed on your system locale, installation problems to find the installer, which was installed in the locale - a query,
But each process the setlocale set its own external encoding attribute,
We use Linux, because we are talking about is to compile and run, so this time our code compiled executable file its environment is called to perform the process, it is the process most (but not certain) is a bash, we the setlocale in the code is installed to perform, at the same time is same and environment Settings/compatible to show the right words, this is me the meaning of "only" yesterday, because we don't have permission to modify the environment a lot of the time, the mountain environment, so only
But for bash, you can make it by changing the environment variable setlocale, export LC_ALL=zh_CN. GBK can bash to make GBK, then your program in the bash GBK words can show normal text,
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Our obstacle lies in the source file itself need UTF8 encoding by default, this is the need of GCC, ordeal GCC is another topic,
Such a non UTF8 bash can run normally and it is the same setlocale executable program, but the cat when the source is garbled,

In conclusion, we generally thought is that because of the source code for the UTF8 GCC by default, so we have to write in UTF8 under the environment of the source code, so we run UTF8 shell, and you run our program in UTF8 shell and normal display character, our program need setlocale in UTF8,
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Of course, if a program is a server program, the execution of it isn't the native display character, that is another matter,

CodePudding user response:

Well, wrong again, before I reply is today, not yesterday,
  • Related