ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 组件源码 ``` /** * <b>方法描述:</b> BCD编码 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-11 11:51:36 <br/> * * @param instr * 入参|输入字符串|{@link java.lang.String} * @param charset * 入参|编码格式|{@link java.lang.String} * @param bcdstr * 出参|十六进制字符串( 31 61...)|{@link java.lang.String} * @return -1 异常<br/> * 0 失败<br/> * 1 成功<br/> */ @Component(label = "BCD编码", style = "处理型", type = "同步组件", comment = "字符串转二进制字符串", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-11 11:51:36") @InParams(param = { @Param(name = "instr", comment = "输入字符串", type = java.lang.String.class), @Param(name = "charset", comment = "编码格式", type = java.lang.String.class) }) @OutParams(param = { @Param(name = "bcdstr", comment = "十六进制字符串( 31 61...)", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase P_bcdEnc(String instr, String charset) { if (charset == null || !Charset.isSupported(charset)) { return ResultBase.newFailureResult("TPTC0004", "bcdEnc-编码方式输入错误:charset="+charset); } if (instr == null || instr == "") { return ResultBase.newSuccessResult(""); } String strTab = "0123456789ABCDEF"; try { byte[] bytes = instr.getBytes(charset); int nChr = bytes[0] >= 0 ? bytes[0] : bytes[0] + 0x100; String strRet = "" + strTab.charAt(nChr >> 4) + strTab.charAt(nChr & 0x0F); for (int i = 1; i < bytes.length; i++) { nChr = bytes[i] >= 0 ? bytes[i] : bytes[i] + 0x100; strRet += " " + strTab.charAt(nChr >> 4) + strTab.charAt(nChr & 0x0F); } return ResultBase.newSuccessResult(strRet); } catch (Exception ex) { AppLog.error(ex); return ResultBase.newExceptionResult("TPTC0005", "bcdEnc-编码方式转换错误:" + AppLog.errorMsg(ex)); } } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/e5/86/e586fe6deeb06f2b4888ef03710e9e1d_1873x864.png) # 参数说明及示例 ## 入口参数 输入字符串:输入一个字符串参数,示例: `abc` 编码格式:设置字符串的编码格式,示例: `utf8` ## 出口参数 十六进制字符串( 31 61...):把输入字符串转换为十六进制字符串,示例: `__INNER__["result"]`