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 实例变量在两个语句中声明和初始化 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
