spicetify/cli · error

file is not in UTF-16LE format: %s

Error message

file is not in UTF-16LE format: %s

What it means

ReadStringFromUTF16Binary requires the input file to be UTF-16LE; it checks for a BOM (0xFF 0xFE) and, if absent, refuses to scan. This error states the file is not UTF-16LE and includes the path. The function cannot safely encode/locate markers in a file of unknown or different encoding.

Source

Thrown at src/utils/file-utils.go:31

	if err != nil {
		return "", -1, -1, fmt.Errorf("error reading file %s: %w", inputFile, err)
	}

	isUTF16LE := false
	if len(fileContent) >= 2 && fileContent[0] == 0xFF && fileContent[1] == 0xFE {
		isUTF16LE = true
	}

	if !isUTF16LE && len(fileContent) > 100 && fileContent[1] == 0x00 {
		isUTF16LE = true
	}

	var startIdx, endIdx int
	var contentToSearch []byte
	var searchStartMarker, searchEndMarker []byte

	if !isUTF16LE {
		return "", -1, -1, fmt.Errorf("file is not in UTF-16LE format: %s", inputFile)
	}

	contentToSearch = fileContent[2:]
	searchStartMarker = encodeUTF16LE(startMarker)
	searchEndMarker = encodeUTF16LE(endMarker)

	startIdx = bytes.Index(contentToSearch, searchStartMarker)
	if startIdx == -1 {
		return "", -1, -1, fmt.Errorf("start marker not found: %s", string(startMarker))
	}

	searchSpace := contentToSearch[startIdx+len(searchStartMarker):]
	endIdx = bytes.Index(searchSpace, searchEndMarker)
	if endIdx == -1 {
		return "", -1, -1, fmt.Errorf("end marker not found after start index %d: %s", startIdx+len(searchStartMarker), string(endMarker))
	}

	stringContentBytes := contentToSearch[startIdx : startIdx+len(searchStartMarker)+endIdx+len(searchEndMarker)]

View on GitHub (pinned to 1f13f73616)

Solutions

  1. Verify you are passing the correct binary file that is stored as UTF-16LE with BOM.
  2. Hexdump the first two bytes; confirm FF FE. If BOM-less UTF-16LE, adjust the caller to strip/insert the BOM handling.
  3. Regenerate the file from Spotify (reinstall/relaunch) if it was corrupted or truncated.
  4. If the newer Spotify format dropped the BOM, use an updated helper that handles BOM-less UTF-16LE.

Example fix

// before
val, _, _, err := utils.ReadStringFromUTF16Binary(cfgPath, start, end)
// after (wrong file — use the UTF-16LE bnk)
val, _, _, err := utils.ReadStringFromUTF16Binary(bnkPath, start, end)
Defensive patterns

Strategy: validation

Validate before calling

head := make([]byte, 2)
f, _ := os.Open(inputFile)
io.ReadFull(f, head)
f.Close()
if head[0] != 0xFF || head[1] != 0xFE {
    return fmt.Errorf("%s has no UTF-16LE BOM", inputFile)
}

Try / catch

val, _, _, err := utils.ReadStringFromUTF16Binary(path, start, end)
if err != nil && strings.Contains(err.Error(), "not in UTF-16LE format") {
    // pick the correct binary or handle BOM-less UTF-16LE yourself
    return err
}

Prevention

When it happens

Trigger: Calling ReadStringFromUTF16Binary on a file lacking the 0xFF 0xFE BOM in its first two bytes — e.g. an ASCII/UTF-8 file, a UTF-16BE file (0xFE 0xFF), or a BOM-less UTF-16LE binary.

Common situations: Pointing the function at the wrong file (a plain-text config instead of the .bnk binary); Spotify rewrote the file without BOM in a newer version; file truncated so the first bytes are gone.

Related errors


AI-assisted analysis of spicetify/cli@1f13f73616 (2026-08-31). Data as JSON: /api/errors/16ca029d769c7e18. Report an issue: GitHub.