首页 > 编程知识 正文

java导出文件名中文乱码,linux查看网络配置的命令

时间:2023-05-06 13:02:17 阅读:41670 作者:464

我和PySide有点问题。 我使用QtCore.QImage处理一些图像,但注意到路径名中没有打开包含unicode字符的图像文件。

于是我开始调查,发现q文件也发生了同样的问题。 在

尝试输入用testring编码的“utf8”和解码的unicode字符串。 两者的区别是一样的。

我也尝试了使用那些QFile.encodeName和QFile.decodeName函数,但是我所做的只是从文件名中删除非ascii字符。 在

我编写这个脚本是为了演示。 #! /usr/高兴的冰淇淋/env python

#-* -编码: utf-8-* -

导入操作系统

from PySide.QtCore import QFile,QIODevice

try:

操作系统. makedirs (u '/tmp/Qt测试' )。

except:

pass #probably dir just exists

操作系统. chdir (u '/tmp/Qt测试' ) )。

defmake_file(fn ) :

f=打开(fn,' w ' ) ) )。

f.close () )

defcheck_file(fn ) :

f=q文件(fn )

f.open(qiodevice.readonly ) )。

return f.is可重写(

fna=u'somefile.txt '

fnu=u'einhverskr.txt '

是make_file(FNA )

是make_file(FNU )

printf nau ' wasopenedsuccessfully 3360 ',check_file(FNA ) )。

printfnuu ' wasopenedsuccessfully 3360 ',check_file(FNU ) )。

print fna u' exists: ',OS.path.exists(FNA ) )。

打印fnu u ' exists : ',OS.path.exists(FNU ) )。

输出功率

^{pr2}$

有人给我说明吗? 在

更新

在查看源代码后,我注意到在unix上,QFile.open ) )总是使用此函数传递文件名。 staticqstringlocale _ decode (constqbytearrayf )。

{

# if定义(q _ OS _ Darwin ) )。

//macalwaysgivesusutf-8 and decomposed,we want that composed .

返回qstring :3360 from utf8(f ).normalized (qstring 33603360 normalization form _ c );

#ElifDefined(q_OS_Symbian ) ) ) ) ) ) ) )。

返回qstring :3360 from utf8(f;

#else

返回字符串:3360从本地8bit (f;

#endif

}

这通常会从字符串中删除unicode字符。 在

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。