unknown encoding to unicode
What would be this encoding's name?
smb://nas/music/_lib/v/voivod/voivod-rrr%C3%B6%C3%B6%C3%B开发者_Go百科6aaarrr/01%20-%20voivod%20-%20rrr%C3%B6%C3%B6%C3%B6aaarrr%20-%20korg%C3%BCll_the_exterminator.mp3
I would like to convert such string to unicode using Python. How would I do that?
That's URL-encoded UTF-8. URL-decode it, then decode it as UTF-8.
Try urllib.unquote().
import urllib
>>> m="smb://nas/music/_lib/v/voivod/voivod-rrr%C3%B6%C3%B6%C3%B6aaarrr/01%20-%20voivod%20-%20rrr%C3%B6%C3%B6%C3%B6aaarrr%20-%20korg%C3%BCll_the_exterminator.mp3"
>>> m1= urllib.unquote(m)
>>> print(repr(m))
'smb://nas/music/_lib/v/voivod/voivod-rrr\xc3\xb6\xc3\xb6\xc3\xb6aaarrr/01 - voivod - rrr\xc3\xb6\xc3\xb6\xc3\xb6aaarrr - korg\xc3\xbcll_the_exterminator.mp3'
>>> m2= m1.decode('utf8')
>>> print(m2)
smb://nas/music/_lib/v/voivod/voivod-rrröööaaarrr/01 - voivod - rrröööaaarrr - korgüll_the_exterminator.mp3
精彩评论