MP3 ID3 文字コード関係を仕様書にあたってみる
仕様がどうなっていようと使ってるやつが対応してないと意味ないですけどね!!
ID3v1
http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm#MPEGTAG
- 文字コードについて記述なし
- title, artist, album それぞれ 30bytes しか書けない
ID3v2
- http://www.id3.org/Developer_Information を見ると 2.3 と 2.4 が active に見える
2.3
- If nothing else is said a string is represented as ISO-8859-1 characters in the range $20 - $FF. Such strings are represented as
, or if newlines are allowed, in the frame descriptions. All Unicode strings use 16-bit unicode 2.0 (ISO/IEC 10646-1:1993, UCS-2). Unicode strings must begin with the Unicode BOM ($FF FE or $FE FF) to identify the byte order.
要は
- ISO-8859-1
- UTF-16
- UTF-16BE
でしか書けない。
2.4
http://www.id3.org/id3v2.4.0-structure
Frames that allow different types of text encoding contains a text
encoding description byte. Possible encodings:
$00 ISO-8859-1 [ISO-8859-1]. Terminated with $00.
$01 UTF-16 [UTF-16] encoded Unicode [UNICODE] with BOM. All
strings in the same frame SHALL have the same byteorder.
Terminated with $00 00.
$02 UTF-16BE [UTF-16] encoded Unicode [UNICODE] without BOM.
Terminated with $00 00.
$03 UTF-8 [UTF-8] encoded Unicode [UNICODE]. Terminated with $00.- ISO-8859-1
- UTF-16
- UTF-16BE
- UTF-8
で書ける。場合によっては ISO-8859-1 と UTF-8 でしか書けない場合がある? (Tag restriction あたり。よくわからない)
個人的なベスト
- ID3v1 は書かない
- 今時 ID3v2 に対応してないプレイヤーとか捨てればいい
- 文字化けの元
- ID3v2.3 にしておく
- 文字コードは UTF-16(LE)