抖音礼物打印机 需要小票打印机一台 代码实现功能: 1、读取抖音直播间弹幕 2、打印出礼物 3、设定规则 可以设置规则 大于多少音浪才打印 4、小尾巴,可以在每条信息的后面,加上 自定义话术 带货话术、今日运势、笑话、算命 、计算抖音等级 等等功能
```java
package com.company;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
public class Main {
public static void main(String[] args) throws UnsupportedEncodingException {
// write your code here
// System.out.println("Hello World!");
//系统的默认编码是GBK
//System.out.println("Default Charset=" + Charset.defaultCharset());
String t = "你好";
byte[] r = t.getBytes("gb2312");
System.out.println(bytes2HexString(r));
}
public static String bytes2HexString(byte[] b) {
String r = "";
for (int i = 0; i < b.length; i++) {
String hex = Integer.toHexString(b[i] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
r += hex.toUpperCase();
}
return r;
}
}
//思路:先转为Unicode,然后转为GBK
// String utf8 = new String(t.getBytes( "UTF-8"));![在这里插入图片描述](https://img-blog.csdnimg.cn/475ed8f1cae9471f96aa521b818e6a03.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA56iL5bqP5ZGYMTI1MTUxNjc=,size_17,color_FFFFFF,t_70,g_se,x_16#pic_center)
// String IOS111 = new String(utf8.getBytes("UTF-8"), "ISO-8859-1");
// String gbk = new String(IOS111.getBytes("ISO-8859-1"), "GBK");
//等同于:
// String utf8 = new String(t.getBytes( "UTF-8"),Charset.defaultCharset());
//System.out.println(utf8);
// String unicode = new String(utf8.getBytes(),"UTF-8");
//等同于:
// String unicode = new String(utf8.getBytes(Charset.defaultCharset()),"UTF-8");
//System.out.println(unicode);
//String gbk = new String(unicode.getBytes("UTF-8"), "GB2312");
// System.out.println(gbk);
//等同于:
// String gbk = new String(unicode.getBytes("GBK"),Charset.defaultCharset());
|