How to handle japenese character in python?

  mutagen, python

Only this error shows no stacktrace.

I have a input coming in japenese language from other source which is out of my control.

But it gives me error

"UnicodeEncodeError: ‘charmap’ codec can’t encode characters in position 15-41: character maps to undefined"

import mutagen

def addTag(fpath, title, albumName):
    audio = mutagen.File(fpath, easy=True)
    audio.add_tags()
    audio['title'] = title
    audio['album'] = albumName
    audio.save(fpath)

# The Code below this comment is out of my control but this is how it is implemented
file = "1.mp3"
title = "We Must Go TV"
album = "アニメ「風が強く吹いている」オリジナルサウンドトラック"
addTag(file, title, album)

Source: Python Questions

LEAVE A COMMENT