Skip to content

0015: Lexical rules ​

Status: Accepted

Context ​

PGN fixes its character-level rules: Latin-1 characters (section 4.1), lines of at most 255 characters with 80 or more "strongly discouraged" (4.3), quoted strings with \" and \\ escapes, no newlines or tabs inside strings, and a 255-character string limit (7), and a game termination marker at the end of every game that matches the Result tag (8.2.6).

Magic data does not fit inside those limits:

  • Card names contain characters outside ASCII, even in English: Lim-Dûl the Necromancer, Jötun Grunt. Player names on MTGO and Arena can contain any character.
  • Oracle names have changed over time. Æther Vial is now Aether Vial in Oracle (checked on Scryfall), but a client may still report an older spelling.
  • Quoted ability text and stack snapshots regularly exceed 80 characters and sometimes 255.
  • Rules text for some cards contains line breaks (for example modal spells, with "Choose one" followed by bulleted modes).
  • Recorders run on both Windows and macOS, and the canonical format (decision 0013) must be byte-for-byte identical.

Decision ​

  1. Files are UTF-8, without a byte-order mark, in Unicode Normalization Form C (NFC). Every character is allowed in names and text. NFC guarantees the same name is always the same bytes.
  2. Card names are written exactly as the Oracle name (decision 0002), including any accented characters. Writers MUST convert source spellings that differ from Oracle (for example a client showing Æther Vial) to the Oracle name.
  3. Lines end with LF (\n) only.
  4. There is no line length limit, and lines are never wrapped. One line holds one event, tag, or table entry.
  5. Quoted strings use PGN escaping: \" for a quote and \\ for a backslash. Additionally, \n represents a line break inside text, since raw newlines are not allowed in strings. There is no string length limit.
  6. Card names, ability text, and other free text are always quoted strings, never bare. Real card names contain characters the format uses as syntax (see the evidence below), so only quoting lets a parser find where a name ends without knowing every card.
  7. Every game ends with a PGN result marker (1-0, 0-1, 1/2-1/2, or *) on its own line, equal to that game's Result tag.

Evidence: card names ​

Checked against 32,220 distinct card names from a Scryfall card database snapshot (the MyMTGO scryfall_cards table, 2026-11-02). This includes non-game cards such as Un-cards, art cards, and World Championship deck cards, so it overstates the problem slightly but covers every real name.

Unquoted, many names would be ambiguous, because they contain characters and words that are also part of .mtgr syntax:

In the nameNamesExampleAlso means, in .mtgr
space29,454Ugin's Labyrinththe separator between tokens on a line
by45Bound by Moonsilverthe start of a cause (decision 0004)
:82Avengers: Under Siegethe separator in cost:#N, rule:sba, and source IDs such as mtgo:19683
( )37Careful Study (minigame)variation brackets (decision 0014)
?1Continue?an unknown value, as in by ?
leading digit970,000 Light-Years from Homean integer
"8+Kongming, "Sleeping Dragon"a string delimiter, so it is escaped as \"
  • No name contains #, {, }, ;, %, [, ], or ->.
  • 944 names are multi-faced cards written with // between faces (decision 0002). Inside a quoted string this needs no special handling.
  • No name contains Æ, which confirms that Oracle uses Ae.
  • 18 distinct non-ASCII characters appear, all accented Latin letters (for example û in Barad-dûr) except ꞉ (U+A789, modifier letter colon) in Ratonhnhaké꞉ton, which looks like a colon but is not one.
  • Every name is already in NFC.

Rules basis ​

Checked against the Comprehensive Rules effective 2026-09-25.

  • 201.2: a card's name is always its English name, regardless of printed language. 108.1: Oracle is the reference for a card's wording. Names are written in English, as in Oracle, which includes non-ASCII characters.

PGN basis, checked against "Standard: Portable Game Notation Specification and Implementation Guide" (Steven J. Edwards, 1994), https://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm:

  • Section 4.1: PGN data uses a subset of ISO 8859/1 (Latin-1).
  • Section 4.3: import format lines are limited to 255 characters, and lines of 80 or more printing characters are strongly discouraged.
  • Section 7: strings are quoted; "a quote inside a string is represented by the backslash immediately followed by a quote", and a backslash by two backslashes; non-printing characters such as newline are not permitted inside strings; strings are limited to 255 characters.
  • Section 8.2.6: each game has exactly one termination marker as its last element, matching its Result tag.

Alternatives rejected ​

  • Latin-1, as in PGN. Rejected: cannot represent every player name, and is an obsolete encoding. UTF-8 is a superset of ASCII, so plain-ASCII files are unchanged.
  • PGN's line length limits and wrapping. Rejected: quoted rules text and stack snapshots exceed them, and wrapping would break one-line-per-event parsing.
  • Raw newlines inside multi-line strings. Rejected: breaks one-line-per-event parsing. \n follows PGN's existing backslash escape style.
  • Keeping the source's spelling of card names. Rejected: the same card would have different names depending on the client, breaking matching across sources.

Consequences ​

  • Departures from PGN (UTF-8, no line limit, \n escape, no string limit) are each justified above under design principle 7.
  • Writers need access to Oracle names to convert outdated source spellings.
  • Conformance fixtures should include non-ASCII card names, a \n in rules text, and a non-NFC file that must be rejected, plus the colliding names above: "Kongming, \"Sleeping Dragon\"", "Bound by Moonsilver", "Avengers Assemble!", "Avengers: Under Siege", "Careful Study (minigame) // Careful Study (cont'd)", and "Ratonhnhaké꞉ton".