在struct dirent可以文件名有非标准字符? [英] In the struct dirent can file names have nonstandard characters?

查看:154
本文介绍了在struct dirent可以文件名有非标准字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

struct dirent 中,成员 d_name 的字符是unicode而不是ascii?我测试,它与'é',但我不知道如果这是因为'é'是在ascii。什么类型是 d_name ,如果它是 char 然后我hooped如果它 wchar_t 我被保存。

In the struct dirent can the member d_name have characters that are unicode but not ascii? I tested and it works with 'é' but I'm not sure if that's because 'é' is in ascii. What type is d_name, if it's char then I'm hooped but if it's wchar_t I'm saved.

推荐答案

开放组基本规格说明 struct dirent 将有以下未指定大小的成员:

The Open Group Base Specifications state that struct dirent shall have the following member of unspecified size:

char d_name[];

在符合的实现中,它的类型是 char [] 但是这并不一定意味着它不能存储Unicode字符;该规范不需要支持多个字符集(或超出便携式字符集的字符),但它不禁止它('é'顺便说一下,是

In conforming implementations it is of type char[] but that doesn't necessarily mean that it can't store Unicode characters; the specification does not require the support of multiple character sets (or characters beyond the portable character set) but it doesn't forbid it either ('é' by the way, is not in ASCII).

实际上,支持的字符集取决于您的区域设置。在C术语中, d_name 中的字符串存储为多字节字符。

In practice, the supported character set depends on your locale. In C terms, the string in d_name is stored as "multi byte" characters.

这篇关于在struct dirent可以文件名有非标准字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆