English 中文(简体)
我如何具体说明(在 Java)UTF-8 I想要的哪一个版本?
原标题:How do I specify which version of UTF-8 I want (in Java)?

Due to some awkward legacy code, I need to pass some non-English text around as ansi/ascii strings that are visibly UTF-8 encoded. For the most part, this is working alright (I m using URLEncoder). However, now I need it to be able to output different versions of UTF-8 in different circumstances, and I don t know how to do that.

For example, this character can be UTF-8 encoded these ways:

大
%u5927
大
%E5%A4%A7

But nothing seems to talk about the different versions, as though there is no difference. I know URLEncoder does not do the second version, because the & is a reserved character, but the second one is what I need in some instances. How can I convert the text to the specific version I want?

Specifically, it s being passed to a .jsp that contains a library called displaytag that handles the data and displays a table without much developer input, but it doesn t seem to have any options for setting the encoding. I know the second encoding (passed as ansi/ascii) in the above list is displays correctly without changing the .jsp, though, which is the safest option for me. I just need to get it that way.

最佳回答

First is the unicode code point in hex and is URL encoded, second is same in decimal and is the HTML/XML entity form.

Never used it for your purpose but I think StringEscapeUtils escapeHtml or escapeXml should give you the second form.

BTW the second form also has a hex version: 大

第三,看一看非图八人意识到的转变功能,这种转变使图八中分别构成单一编码点的三条 by子转变。 我认为,第三点是不正确的,因为你看不到三点 by,或事实上是ut八。

问题回答

From what I can gather from the question, all you really want to ultimately do is display text.

你已经知道,存储在记忆中或档案中的内容是按顺序排列的,纯粹是简单的,有些是,你有三重顺序,即5 a4 a7,因为这正是UTF-8编码的OOKIIOO HAJIM INI。

如果用 Java语将这种特性放在URL中,那么你使用URLEncoder,你将获得%E5%A4A7。 但是,如果你想在联合项目上展示,我一定会建议超文本实体<代码>&#x5927;。 因为,如果你决定寄送UTF-8的原始tes子,那么,你们的电灯要由终端用户打上其 character子的 character子。

如何做到这一点,取决于贵数据是否作为直径储存,还是真正的 Java。 一般来说,对于产出超额计数实体,你可以通过将每一特性与高于7F的代码相转换为形式特征,在方案上这样做。

& # x codepoint ;

或为你寻找图书馆。 如果你处理一阵列,这或许会更多工作,但可以这样做。 Lang s StringE PinheiroUtils共同公司处理已知的指定实体,但我不认为这将为具有较大密码点的特性创建数字超文本实体。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签