How to define a new Charset in Java/Android?(如何在 Java/Android 中定义一个新的字符集?)
问题描述
在台湾,我们有一种称为Unicode At One (UAO)"的字符编码,它是 BIG-5 的扩展,但 Java 和 Android 不支持.
代码页位于 http://moztw.org/docs/big5/table/uao241-b2u.txt
in Taiwan we have a character encoding called "Unicode At One (UAO)", which is an extension to BIG-5 but is not supported by Java and Android.
The code page is in http://moztw.org/docs/big5/table/uao241-b2u.txt
我的问题是,如何使用这个 Charset 构建一个包含字节数组数据的 String 对象?
我想我会扩展 String 类并在其中做一些事情,但我不知道如何创建一个新的 Charset.
My question is, how can I build a String object with byte array data, using this Charset?
I guess I will extend the String class and do something in it, but I have no idea how to create a new Charset.
推荐答案
您可以添加自己的 Charset
通过编写 CharsetProvider
并通过服务发现机制注册它.
You can add your own Charset
implementation by writing a CharsetProvider
and registering it via the service discovery mechanism.
您需要扩展 Charset
并实现其 newDecoder
和 newEncoder
方法返回适当的CharsetDecoder
和 CharsetEncoder
.
You'll need to extend Charset
and implements its newDecoder
and newEncoder
methods to return an appropriate CharsetDecoder
and CharsetEncoder
respectively.
这篇关于如何在 Java/Android 中定义一个新的字符集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Java/Android 中定义一个新的字符集?


基础教程推荐
- 存储 20 位数字的数据类型 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 如何对 Java Hashmap 中的值求和 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01