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 中定义一个新的字符集?


基础教程推荐
- 降序排序:Java Map 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01