Ubunut10.04×1Rhythmbox Shift-JIS文字化け対策
環境
- Ubuntu10.04
- Rhythmbox0.12.8
概要
Windowsで取り込んだMP3ファイルをUbuntuのRhythmboxにインポートするとタイトル等の文字化けが発生した。それを修正するための方法をメモっておく。検索すればヒットはするけど、メモメモ。。。
1.RhythmboxにMP3ファイルをインポート
2.Rhythmboxを終了させる!
3.Ubuntuの[アプリケーション]-[アクセサリ]-[端末]を起動
4.cd /home/ユーザー名/.local/share/rhythmbox
*1
5.cp rhythmdb.xml rhythmdb.xml.org
*2
6.gedit /bin/convert_rhythmdb.pl
以下の内容をエディタで作成*3
#! /usr/bin/perl # rhythmbox変換スクリプト use Encode; #エンコード用のperlライブラリ? while (<>) { # <artist>の行だけ変換 if (/<artist>/) { # Shift_JISの文字参照をバイナリに戻す s/\&\#x([0-9A-Fa-f]{2});/pack 'C', hex($1)/ge; # UTF-8に変換 $artist_utf = decode('Shift_JIS', $_); print $artist_utf; } # <title>の行だけ変換 elsif (/title/) { s/\&\#x([0-9A-Fa-f]{2});/pack 'C', hex($1)/ge; $title_utf = decode('Shift_JIS', $_); print $title_utf; } # <genre>の行だけ変換 elsif (/genre/) { s/\&\#x([0-9A-Fa-f]{2});/pack 'C', hex($1)/ge; $genre_utf = decode('Shift_JIS', $_); print $genre_utf; } # <album>の行だけ変換 elsif (/album/) { s/\&\#x([0-9A-Fa-f]{2});/pack 'C', hex($1)/ge; $album_utf = decode('Shift_JIS', $_); print $album_utf; } #他の行は変換せずに表示 else { print; } }
7.chmod +x /bin/convert_rhythmdb.pl
*4
8.cd /home/ユーザー名/.local/share/rhythmbox
9.convert_rhythmdb.pl < rhythmdb.xml.org > rhythmdb.xml
10.終了です。お疲れさまでした。
参考サイト
以下のサイトを参考にさせていただきました。ありがとうございます。記述内容に問題があればコメントください。訂正します。