Utf 8 包含超级字符串的文件名导致gsutil错误

Utf 8 包含超级字符串的文件名导致gsutil错误,utf-8,google-cloud-storage,Utf 8,Google Cloud Storage,我有一个从终端运行的脚本,在Centos 7中使用gsutil上传文件,我收到一个关于我的一个文件名的错误 Caught non-retryable exception while listing file:///home//: CommandException: Invalid Unicode path encountered ('/home/mysite/public_html/images/office-100-m\xe2\xb2.jpg'). 我像这样签入python(注意超弦): 它

我有一个从终端运行的脚本,在Centos 7中使用gsutil上传文件,我收到一个关于我的一个文件名的错误

Caught non-retryable exception while listing file:///home//:
CommandException: Invalid Unicode path encountered
('/home/mysite/public_html/images/office-100-m\xe2\xb2.jpg').
我像这样签入python(注意超弦):

它能解码吗?我希望看到一个错误。当我检查区域设置时

python -c "import locale; print locale.getdefaultlocale()"
('en_US', 'UTF-8')

那么它有什么问题呢?

该字符串不是有效的unicode序列。如果您获取字节并尝试对其进行解码,您将看到错误:

>>> s = '/home/mysite/public_html/images/office-100-m\xe2\xb2.jpg'
>>> s.decode('utf-8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 44-45: invalid continuation byte

注意
\xc2\xb2
\xe2\xb2
的对比。我不确定文件系统文件名的编码是什么,但它似乎不是UTF-8。

该字符串不是有效的unicode序列。如果您获取字节并尝试对其进行解码,您将看到错误:

>>> s = '/home/mysite/public_html/images/office-100-m\xe2\xb2.jpg'
>>> s.decode('utf-8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 44-45: invalid continuation byte

注意
\xc2\xb2
\xe2\xb2
的对比。我不确定文件系统文件名的编码是什么,但它似乎不是UTF-8。

是否有命令列出文件系统使用的编码?还是以文件为基础?(这是使用google compute engine在安装过程中提供的默认centos 7映像)是否有命令列出我的文件系统使用的编码?还是以文件为基础?(这是使用谷歌计算引擎在安装过程中提供的默认centos 7图像)
>>> u"office-100-m²-2.jpg".encode('utf-8')
'office-100-m\xc2\xb2-2.jpg'