forked from demo/example
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
834 B
25 lines
834 B
6 years ago
|
// 自定义函数Unicode编码转化为中文
|
||
|
package com.fr.function;
|
||
|
|
||
|
import com.fr.script.AbstractFunction;
|
||
|
|
||
|
public class Ubm extends AbstractFunction {
|
||
|
public Object run(Object[] args) {
|
||
|
String str = args[0].toString();
|
||
|
String st = "";
|
||
|
StringBuffer buffer = new StringBuffer();
|
||
|
while (str.length() > 0) {
|
||
|
if (str.startsWith("%u")) {
|
||
|
st = str.substring(2, 6);
|
||
|
char ch = (char) Integer.parseInt(String.valueOf(st), 16);
|
||
|
buffer.append(new Character(ch).toString());
|
||
|
str = str.substring(6);
|
||
|
} else {
|
||
|
st = str.substring(0, str.indexOf("%u"));
|
||
|
buffer.append(st);
|
||
|
str = str.substring(st.length());
|
||
|
}
|
||
|
}
|
||
|
return buffer.toString();
|
||
|
}
|
||
6 years ago
|
}
|