learning java Encoder and Decoder
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder; public class CharsetTransform {
public static void main(String[] args) throws CharacterCodingException {
Charset cn = Charset.forName("GBK");
CharsetEncoder cnEncoder = cn.newEncoder();
CharsetDecoder cnDecoder = cn.newDecoder(); CharBuffer cbuff = CharBuffer.allocate();
cbuff.put("良红");
cbuff.flip();
ByteBuffer bbuff = cnEncoder.encode(cbuff);
for (var i =; i < bbuff.capacity(); i++){
System.out.println(bbuff.get(i) + " ");
}
System.out.println("\n" + cnDecoder.decode(bbuff)); }
}
output:
-63
-68
-70
-20 良红
learning java Encoder and Decoder的更多相关文章
- 从Encoder到Decoder实现Seq2Seq模型
https://zhuanlan.zhihu.com/p/27608348 更新:感谢@Gang He指出的代码错误.get_batches函数中第15行与第19行,代码已经重新修改,GitHub已更 ...
- Learning Java language Fundamentals
Chapter 2 Learning Java language fundamentals exercises: 1.What is Unicode? Unicode is a computing ...
- C# 字符编码解码 Encoder 和Decoder
在网络传输和文件操作中,如果数据量很大,需要将其划分为较小的快,此时可能出现一个数据块的末尾是一个不匹配的高代理项,而与其匹配的低代理项在下一个数据块. 这时候使用Encoding的GetBytes方 ...
- TF之AE:AE实现TF自带数据集AE的encoder之后decoder之前的非监督学习分类—Jason niu
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt #Import MNIST data from t ...
- TF之AE:AE实现TF自带数据集数字真实值对比AE先encoder后decoder预测数字的精确对比—Jason niu
import tensorflow as tf import numpy as np import matplotlib.pyplot as plt #Import MNIST data from t ...
- blogs for learning java
曹海成的专栏 http://blog.csdn.net/caohaicheng/article/details/38071097 http://blog.csdn.net/a5489888/artic ...
- Learning Java IO indexes
I/O Streams, it simplifies I/O operations, write a whole object out to stream & read back. File ...
- Learning Java 8 Syntax (Java in a Nutshell 6th)
Java is using Unicode set Java is case sensitive Comments, C/C++ style abstract, const, final, int, ...
- Learning Java characteristics (Java in a Nutshell 6th)
Java characteristics: Java .class files are machine-independent, including the endianness. Java .cla ...
随机推荐
- 2. matplotlib绘制散点图
与绘制直线图的唯一区别:plt.scatter # coding=utf-8 from matplotlib import pyplot as plt from matplotlib import f ...
- sqoop从mysql导数据到hive报错:Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
背景 使用sqoop从mysql导数据到hive,从本地服务器是可以访问mysql的(本地服务器是hadoop集群的一个datanode),但是sqoop导数据的时候依然连接不上mysql 报错如下: ...
- Node.js实现用户评论社区(体验前后端开发的乐趣)
前面 接着上一节的内容来,今天我们要完成一个用Node开发后台服务器,实现一个简单的用户评论社区.可以先看下效果图: 开始 建立项目文件夹comment-list,在里面新建一个public文件夹,p ...
- 基于代理类实现Spring AOP
目录 ProxyFactoryBean类介绍 基于JDK动态代理的Spring AOP实现 基于CGLIB代理的Spring AOP实现 Spring的通知类型 ProxyFactoryBean类 ...
- Implement CGLIB in ABAP
What is cglib?A Byte Code Generation Library which is high level API to generate and transform Java ...
- maven 修改镜像为阿里淘宝源
修改maven根目录下的conf文件夹中的setting.xml文件,(或者当前用户目录 的 .m2 目录下的 setting.xml 文件) 内容如下: <mirrors> <mi ...
- Python学习日记(二十八) hashlib模块、configparse模块、logging模块
hashlib模块 主要提供字符加密算法功能,如md5.sha1.sha224.sha512.sha384等,这里的加密算法称为摘要算法.什么是摘要算法?它又称为哈希算法.散列算法,它通过一个函数把任 ...
- golang读写文件
1. 标准输入输出 os提供了标准输入输出文件: Stdin = NewFile(uintptr(syscall.Stdin), "/dev/stdin") Stdout = Ne ...
- 接口测试 dubbo 接口测试技术
本文转自测试之家 https://testerhome.com/topics/10481 dubbo是阿里巴巴开源的一套rpc方案,以为理念很契合微服务,这几年很火,用户里面不凡京东,当当,去哪儿等大 ...
- Android打包遇到的问题
问题一 运行环境 引擎:Unity 4.3.4f1 安卓:Android 6 打包机的环境 出错堆栈 Unity version : 4.3.4f1 Caused by: java.lang.Unsa ...