NetMD.Titles (NetMD v0.1.0)

Copy Markdown View Source

Title sanitization for MiniDisc TOC entries, ported from netmd-js.

Half-width titles allow ASCII plus half-width katakana; full-width titles allow the two-byte Shift-JIS character set. Both sanitizers fall back to an aggressive ASCII-only strip when the result would not encode cleanly. The mapping tables are extracted verbatim from the reference source by tools/gen_title_tables.ts.

Summary

Functions

Strip a title down to plain ASCII.

Length of a title in half-width character cells; voiced kana take two.

Convert a track range like "1-5" to its full-width form. Characters outside 0-9, -, / and ; are dropped.

Replace diacritics with their base characters, like the diacritics package used by the reference.

Sanitize a title for the full-width (two bytes per character) TOC slot.

Sanitize a title for the half-width (ASCII and half-width kana) TOC slot.

Functions

aggressive_sanitize(title)

@spec aggressive_sanitize(String.t()) :: String.t()

Strip a title down to plain ASCII.

half_width_length(title)

@spec half_width_length(String.t()) :: non_neg_integer()

Length of a title in half-width character cells; voiced kana take two.

half_width_to_full_width_range(range)

@spec half_width_to_full_width_range(String.t()) :: String.t()

Convert a track range like "1-5" to its full-width form. Characters outside 0-9, -, / and ; are dropped.

remove_diacritics(string)

@spec remove_diacritics(String.t()) :: String.t()

Replace diacritics with their base characters, like the diacritics package used by the reference.

sanitize_full_width(title, opts \\ [])

@spec sanitize_full_width(
  String.t(),
  keyword()
) :: String.t()

Sanitize a title for the full-width (two bytes per character) TOC slot.

With just_remap: true only the character remapping runs, without the encoding check and fallback.

sanitize_half_width(title)

@spec sanitize_half_width(String.t()) :: String.t()

Sanitize a title for the half-width (ASCII and half-width kana) TOC slot.