jldupont
jldupont

Reputation: 96716

unknown encoding to unicode

What would be this encoding's name?

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

I would like to convert such string to unicode using Python. How would I do that?

Upvotes: 0

Views: 911

Answers (3)

tzot
tzot

Reputation: 95901

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

Upvotes: 0

Russell Borogove
Russell Borogove

Reputation: 19037

Try urllib.unquote().

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798486

That's URL-encoded UTF-8. URL-decode it, then decode it as UTF-8.

Upvotes: 3

Related Questions