{"record":{"id":"308829ee32dbe41e","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-s-s-l","errorCode":null,"errorMessage":"[\" cimg_appname \"_math_parser] CImg<%s>::%s: %s: Literal %s contains more than one byte, in expression '%s'.","messagePattern":"\\[\" cimg_appname \"_math_parser\\] CImg<(.+?)>::(.+?): (.+?): Literal (.+?) contains more than one byte, in expression '(.+?)'\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":24500,"sourceCode":"\n        // Char / string initializer.\n        if (*se1=='\\'' &&\n            ((se1>ss && *ss=='\\'') ||\n            (se1>ss1 && *ss=='_' && *ss1=='\\''))) {\n          if (*ss=='_') { _cimg_mp_op(\"Char initializer\"); s1 = ss2; }\n          else { _cimg_mp_op(\"String initializer\"); s1 = ss1; }\n          arg1 = (unsigned int)(se1 - s1); // Original string length\n          if (arg1) {\n            CImg<charT>(s1,arg1 + 1).move_to(variable_name).back() = 0;\n            cimg::strunescape(variable_name);\n            arg1 = (unsigned int)std::strlen(variable_name);\n          }\n          if (!arg1) _cimg_mp_return(0); // Empty string -> 0\n          if (*ss=='_') {\n            if (arg1==1) _cimg_mp_const_scalar((unsigned char)*variable_name);\n            cimg::strellipsize(variable_name,64);\n            _cimg_mp_strerr;\n            throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                        \"CImg<%s>::%s: %s: Literal %s contains more than one byte, \"\n                                        \"in expression '%s'.\",\n                                        pixel_type(),_cimg_mp_calling_function,s_op,\n                                        ss1,s0);\n          }\n          pos = vector(arg1);\n          CImg<ulongT>::vector((ulongT)mp_string_init,pos,arg1).move_to(l_opcode);\n          CImg<ulongT>(1,arg1/sizeof(ulongT) + (arg1%sizeof(ulongT)?1:0)).move_to(l_opcode);\n          std::memcpy((char*)l_opcode[1]._data,variable_name,arg1);\n          (l_opcode>'y').move_to(is_inside_begin || is_new_variable_assignment?code:code_begin);\n          return_comp = is_new_variable_assignment;\n          if (!return_comp) set_reserved_vector(pos); // Prevent from being used in further optimization\n          _cimg_mp_return(pos);\n        }\n\n        // Vector initializer [ ... ].\n        if (*ss=='[' && *se1==']') {\n          _cimg_mp_op(\"Vector initializer\");","sourceCodeStart":24482,"sourceCodeEnd":24518,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L24482-L24518","documentation":"CImg's math parser supports character literals (e.g. 'A') as single-byte values. This error is thrown when a quoted literal intended as a character contains more than one byte — the parser cannot represent it as a single scalar. Note the parser works on bytes, so multi-byte UTF-8 characters also trigger it.","triggerScenarios":"Evaluating an expression containing a multi-character quoted literal such as 'ab' or a multi-byte UTF-8 character like 'é' where a single-char literal is expected (parsed via the string-literal branch that ends with _cimg_mp_const_scalar((unsigned char)*variable_name)).","commonSituations":"Using typographic quotes or accented characters inside fill() expressions; accidentally leaving two characters inside quotes; non-ASCII input from config files or user text pasted into expressions.","solutions":["Reduce the quoted literal to exactly one ASCII character.","For multi-byte characters, use the byte value(s) explicitly, e.g. via char codes or multiple one-byte literals.","Strip or replace typographic/unicode quotes with straight ASCII quotes.","Sanitize expressions built from user/config input to ASCII before passing to CImg.","If a string is needed, use CImg string-handling functions instead of char literals."],"exampleFix":"// before\nimg.fill(\"X=='é'\"); // multi-byte UTF-8 literal\n// after\nimg.fill(\"X==233\"); // explicit code point, or single-byte 'e'","handlingStrategy":"validation","validationCode":"String s = \"'X'\";\nif (s.length() - 2 != 1 || !isAscii(s.charAt(1))) throw new IllegalArgumentException(\"char literal must be one ASCII byte\");","typeGuard":null,"tryCatchPattern":"try {\n    img.fill(expression);\n} catch (CImgInstantiationException e) {\n    if (e.getMessage().contains(\"contains more than one byte\")) {\n        // replace offending literal with a numeric code point\n    }\n    throw e;\n}","preventionTips":["Restrict expression input to ASCII.","Replace typographic/unicode quotes and accented characters before passing expressions to CImg.","Prefer numeric code points over character literals for non-ASCII values."],"tags":["cimg","math-parser","character-literal","encoding"],"backgroundTag":"invalid-argument-format","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}