Skip to content

“设置标准库调用系统 API 所用的编码,用于 fopen,ifstream 等函数 ”。具体是通过什么字段来影响? #14

Open
@bxhuanxue

Description

@bxhuanxue

小彭老师好😋
我有个问题想请教一下

setlocale(LC_ALL, ".utf-8"); // 设置标准库调用系统 API 所用的编码,用于 fopen,ifstream 等函数

根据我的理解,fopen 函数主要创建一个 FILE 结构体,和用户缓冲区,其中包含了管理文件操作的多个字段。然而,在查看 struct _IO_FILE 时,我注意到并没有明确setlocale相关字段。以下是该结构体:

struct _IO_FILE
{
int _flags; /* High-order word is _IO_MAGIC; rest is flags. */

/* The following pointers correspond to the C++ streambuf protocol. */
char _IO_read_ptr; / Current read pointer */
char _IO_read_end; / End of get area. */
char _IO_read_base; / Start of putback+get area. */
char _IO_write_base; / Start of put area. */
char _IO_write_ptr; / Current put pointer. */
char _IO_write_end; / End of put area. */
char _IO_buf_base; / Start of reserve area. */
char _IO_buf_end; / End of reserve area. */

/* The following fields are used to support backing up and undo. */
char _IO_save_base; / Pointer to start of non-current get area. */
char _IO_backup_base; / Pointer to first valid character of backup area */
char _IO_save_end; / Pointer to end of non-current get area. */

struct _IO_marker *_markers;

struct _IO_FILE *_chain;

int _fileno;
int _flags2;
__off_t _old_offset; /* This used to be _offset but it's too small. */

/* 1+column number of pbase(); 0 is unknown. */
unsigned short _cur_column;
signed char _vtable_offset;
char _shortbuf[1];

_IO_lock_t *_lock;
#ifdef _IO_USE_OLD_IO_FILE
};
我想了解“设置标准库调用系统 API 所用的编码,用于 fopen,ifstream 等函数 ”。具体是通过什么字段来影响呢💕

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions