{"record":{"id":"1db486eb69b04d7c","repo":"kitao/pyxel","slug":"unsupported-encoding-in-file-path","errorCode":null,"errorMessage":"Unsupported encoding in file '{path}'","messagePattern":"Unsupported encoding in file '(.+?)'","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pyxel-core/src/tmx_parser.rs","lineNumber":78,"sourceCode":"\n    if tmx.tilewidth != TILE_SIZE || tmx.tileheight != TILE_SIZE {\n        return Err(err(\"Invalid tile size in file\"));\n    }\n\n    let tileset = tmx\n        .tilesets\n        .first()\n        .ok_or_else(|| err(\"No tileset found in file\"))?;\n    let columns = tileset\n        .columns\n        .ok_or_else(|| err(\"No embedded tileset in file\"))?;\n\n    let layer = tmx\n        .layers\n        .get(layer_index as usize)\n        .ok_or_else(|| format!(\"Layer {layer_index} not found in file '{path}'\"))?;\n    if layer.data.encoding != \"csv\" {\n        return Err(err(\"Unsupported encoding in file\"));\n    }\n\n    let tile_ids: Vec<u32> = remove_whitespace(&layer.data.tiles)\n        .split(',')\n        .map(|s| s.parse::<u32>().map_err(|_| err(\"Failed to parse file\")))\n        .collect::<Result<_, _>>()?;\n\n    // Convert TMX global tile IDs into Pyxel image tile coordinates.\n    let tilemap = Tilemap::try_new(layer.width, layer.height, ImageSource::Index(0))\n        .map_err(|_| err(\"Layer dimensions are too large in file\"))?;\n    let mut tilemap_ref = rc_mut!(tilemap);\n    for (y, row) in tile_ids.chunks(layer.width as usize).enumerate() {\n        for (x, &id) in row.iter().enumerate() {\n            let id = (id & !TMX_TILE_FLAG_MASK).saturating_sub(tileset.firstgid);\n            tilemap_ref.canvas.write_data(\n                x,\n                y,\n                (","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/kitao/pyxel/blob/50f9bd77780c993aca62b5b221766bde5791081d/crates/pyxel-core/src/tmx_parser.rs#L60-L96","documentation":"The layer's tile data is not CSV-encoded. The parser only supports `encoding=\"csv\"`; TMX also allows base64 (optionally zlib/gzip compressed) encodings, which this library cannot decode and rejects explicitly. The message is emitted from the `if layer.data.encoding != \"csv\"` branch.","triggerScenarios":"parse_tmx reads a <layer><data> element whose @encoding is anything other than \"csv\" (e.g. \"base64\", \"base64+zlib\", \"base64+gzip\").","commonSituations":"Exporting from Tiled with the default base64 encoding; opening a map saved with compression enabled; upgrading a project where the map export settings changed from CSV to base64.","solutions":["In Tiled, set Preferences > Editing > Layer Data format to CSV and re-save the map","Decode base64 (and decompress zlib/gzip) tile data yourself, then rewrite the layer as CSV before calling parse_tmx","Use Tiled to re-export the map with CSV layer data","Check the <data encoding=\"...\"> attribute in the TMX and convert non-CSV layers with a script"],"exampleFix":"// before\n<data encoding=\"base64\" compression=\"zlib\">eJzt...</data>\n// after\n<data encoding=\"csv\">1,2,3,4,...</data>","handlingStrategy":"validation","validationCode":"fn layer_is_csv(tmx_path: &str) -> std::io::Result<bool> {\n    let xml = std::fs::read_to_string(tmx_path)?;\n    Ok(xml.contains(\"encoding=\\\"csv\\\"\"))\n}","typeGuard":null,"tryCatchPattern":"match parse_tmx(path, layer_index) {\n    Ok(tilemap) => tilemap,\n    Err(msg) if msg.starts_with(\"Unsupported encoding\") => {\n        eprintln!(\"re-export the map with CSV layer data: {msg}\");\n        return Err(msg);\n    }\n    Err(msg) => return Err(msg),\n}","preventionTips":["Set Tiled's layer data format to CSV in Preferences before saving maps","Grep exported maps for encoding=\"base64\" as part of the build pipeline","Document the CSV-only requirement in your asset-authoring guide"],"tags":["tmx","parser","encoding","unsupported-format"],"backgroundTag":"unsupported-encoding","analyzedSha":"50f9bd77780c993aca62b5b221766bde5791081d","analyzedAt":"2026-09-03T10:27:43.285Z","contentChangedAt":"2026-09-03T10:27:43.285Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}