{"record":{"id":"f66f5c33cecdd7c9","repo":"TheAlgorithms/Go","slug":"c-does-not-exist-in-characters","errorCode":null,"errorMessage":"%c does not exist in characters","messagePattern":"%c does not exist in characters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cipher/polybius/polybius.go","lineNumber":95,"sourceCode":"\nfunc (p *Polybius) encipher(char rune) (string, error) {\n\tindex := strings.IndexRune(p.key, char)\n\tif index < 0 {\n\t\treturn \"\", fmt.Errorf(\"%q does not exist in keys\", char)\n\t}\n\trow := index / p.size\n\tcol := index % p.size\n\tchars := []rune(p.characters)\n\treturn string([]rune{chars[row], chars[col]}), nil\n}\n\nfunc (p *Polybius) decipher(chars []rune) (string, error) {\n\tif len(chars) != 2 {\n\t\treturn \"\", fmt.Errorf(\"the size of \\\"chars\\\" must be even\")\n\t}\n\trow := strings.IndexRune(p.characters, chars[0])\n\tif row < 0 {\n\t\treturn \"\", fmt.Errorf(\"%c does not exist in characters\", chars[0])\n\t}\n\tcol := strings.IndexRune(p.characters, chars[1])\n\tif col < 0 {\n\t\treturn \"\", fmt.Errorf(\"%c does not exist in characters\", chars[1])\n\t}\n\treturn string(p.key[row*p.size+col]), nil\n}\n","sourceCodeStart":77,"sourceCodeEnd":103,"githubUrl":"https://github.com/TheAlgorithms/Go/blob/5ba447ec5ff3d1213de65b92e726ee74c5d5cc19/cipher/polybius/polybius.go#L77-L103","documentation":"decipher resolves the row/column via strings.IndexRune in the cipher's character alphabet; a rune not in 'characters' (e.g. text not produced by this cipher) yields -1 and triggers this error naming the character.","triggerScenarios":"Thrown at cipher/polybius/polybius.go:95 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate ciphertext characters against the cipher alphabet before decrypting","Ensure encrypt/decrypt use the same size and characters configuration","Strip or reject foreign characters in the input"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ba447ec5ff3d1213de65b92e726ee74c5d5cc19","analyzedAt":"2026-09-02T21:54:30.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}