小编bhh*_*988的帖子

opendir 和 readdir 在我背后编码字符串?

(如果你能回答这个问题,你可以跳过最后几行的细节:))

我在 Ubuntu 12.04 上。我正在尝试解决我过去发布的一个旧问题(如果您好奇:https : //superuser.com/questions/339877/trouble-viewing-files-with-non-english-names -on-hard-disk/339895#339895)。Linux、Mac、HFS+ 和以韩文命名的文件之间存在一个已知的兼容性问题,我今天花了一整天时间试图最终找到某种解决方法。

基本上,我已经将我的 HFS+ 驱动器安装到了 linux 上。普通 ls 和 cd 无法访问文件,因为它们是韩文。所以我写了一个 C 程序来尝试在最低级别访问这些文件,所以我可以更确定在我背后不会发生任何事情:

DIR* dp; 
struct dirent *ep;
char* parent = "/media/external/Movies";
dp = opendir( parent );
if( dp != NULL )
{   
    while( ep = readdir(dp) )
    {   
        printf( "%d %s %X\t", ep->d_ino, ep->d_name, ep->d_type );

    // now print out the filenames in hex
        for( int i = 0; i != strlen( ep->d_name ) ; i++)
        {   
            printf( "0x%X " …
Run Code Online (Sandbox Code Playgroud)

character-encoding directory-structure

6
推荐指数
1
解决办法
2256
查看次数