{"record":{"id":"2e735a7546c9ac95","repo":"alibaba/DataX","slug":"ascii-s-ascii","errorCode":null,"errorMessage":"根据字符串进行切分时仅支持 ASCII 字符串，而字符串:[%s]非 ASCII 字符串.","messagePattern":"根据字符串进行切分时仅支持 ASCII 字符串，而字符串:\\[(.+?)\\]非 ASCII 字符串\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/com/alibaba/datax/common/util/RangeSplitUtil.java","lineNumber":121,"sourceCode":"     * 由于只支持 ascii 码对应字符，所以radix 范围为[1,128]\n     */\n    public static BigInteger stringToBigInteger(String aString, int radix) {\n        if (null == aString) {\n            throw new IllegalArgumentException(\"参数 bigInteger 不能为空.\");\n        }\n\n        checkIfBetweenRange(radix, 1, 128);\n\n        BigInteger result = BigInteger.ZERO;\n        BigInteger radixBigInteger = BigInteger.valueOf(radix);\n\n        int tempChar;\n        int k = 0;\n\n        for (int i = aString.length() - 1; i >= 0; i--) {\n            tempChar = aString.charAt(i);\n            if (tempChar >= 128) {\n                throw new IllegalArgumentException(String.format(\"根据字符串进行切分时仅支持 ASCII 字符串，而字符串:[%s]非 ASCII 字符串.\", aString));\n            }\n            result = result.add(BigInteger.valueOf(tempChar).multiply(radixBigInteger.pow(k)));\n            k++;\n        }\n\n        return result;\n    }\n\n    /**\n     * 把BigInteger 转换为 String.注意：radix 和 basic 范围都为[1,128], radix + basic 的范围也必须在[1,128].\n     */\n    private static String bigIntegerToString(BigInteger bigInteger, int radix) {\n        if (null == bigInteger) {\n            throw new IllegalArgumentException(\"参数 bigInteger 不能为空.\");\n        }\n\n        checkIfBetweenRange(radix, 1, 128);\n","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/alibaba/DataX/blob/80ec23d5c5328eb90ca364d2749e92dfaf44541e/common/src/main/java/com/alibaba/datax/common/util/RangeSplitUtil.java#L103-L139","documentation":"stringToBigInteger only supports ASCII: any character with code >= 128 triggers IllegalArgumentException. String splitting works by treating each char as a digit (value = char code) in base `radix`; non-ASCII characters break this positional encoding, so the utility rejects them explicitly, echoing the offending string.","triggerScenarios":"Passing a string containing Chinese characters, emoji, or any non-ASCII byte (e.g. '订单2021', 'café') to stringToBigInteger — directly or via a string splitPk whose min/max boundaries contain non-ASCII data.","commonSituations":"Choosing a varchar splitPk column that stores Chinese or other multibyte text; test data seeded with unicode strings; migration jobs on multilingual tables.","solutions":["Choose a splitPk column restricted to ASCII (ids, codes, hashes like MD5).","If the column may contain non-ASCII, remove splitPk so the table is not split (single channel) or split on another key.","Pre-validate with a regex such as ^\\x00-\\x7F]+$ before attempting a string split."],"exampleFix":"// before\nBigInteger v = RangeSplitUtil.stringToBigInteger(splitPkValue, RADIX);\n\n// after\nif (!splitPkValue.matches(\"[\\u0000-]*\")) {\n    throw DataXException.asDataXException(CommonErrorCode.CONFIG_ERROR,\n        \"splitPk column contains non-ASCII value: \" + splitPkValue);\n}\nBigInteger v = RangeSplitUtil.stringToBigInteger(splitPkValue, RADIX);","handlingStrategy":"validation","validationCode":"private static final Pattern ASCII = Pattern.compile(\"^\\u0000-\\u007F]*$\");\nif (!ASCII.matcher(str).matches()) {\n    throw new IllegalArgumentException(\"non-ASCII splitPk value: \" + str);\n}\nBigInteger v = RangeSplitUtil.stringToBigInteger(str, radix);","typeGuard":"static boolean isPureAscii(String s) {\n    if (s == null) return false;\n    for (int i = 0; i < s.length(); i++) if (s.charAt(i) >= 128) return false;\n    return true;\n}","tryCatchPattern":null,"preventionTips":["Restrict string splitPk to ASCII-safe columns (hashes, ids).","Screen sample values for unicode before choosing a splitPk."],"tags":["datax","split","string","ascii","unicode"],"backgroundTag":null,"analyzedSha":"80ec23d5c5328eb90ca364d2749e92dfaf44541e","analyzedAt":"2026-08-14T15:33:51.187Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}