我应该在XML文件中为DOM Parser指定哪种编码来解析Tamil,Telugu,Malayalam和其他印度区域语言脚本?

时间:2016-12-28 09:44:31

标签: java xml swing encoding utf-8

  

UTF-8

     

ISO-8859-1

     

TACE16

     

ISCII泰米尔语

     

TSCII

我已经尝试了所有上述标准,DOM Parser无法对包含区域语言脚本的XML文件进行编码。

应该使用哪种编码标准
  

泰米尔语

     

泰卢固

     

马来亚

     

埃纳德语

UTF-8适用于马拉地语和印地语。

这是我的xml文件

<?xml version="1.0" encoding="UTF-8"?>
<ihelp>
<home>வீடு</home>
</ihelp> 

我使用DOM解析器来解析xml文件。

System.out.println(eElement.getElementsByTagName("home").item(0).getTextContent());

这会在控制台中打印编码值வீடு

但是,

homeButton.setText(eElement.getElementsByTagName("home").item(0).getTextContent());

没有在按钮上打印字符串வீடு

我正在使用Eclipse并致力于Java Swing。

修改

我使用单选按钮选择语言。当我在区域语言选项和英语语言选项之间进行选择时,我会在控制台中获得以下日志。

  

com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException:   1字节UTF-8序列的字节1无效。在   com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:701)     在   com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:567)     在   com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1896)     在   com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipChar(XMLEntityScanner.java:1551)     在   com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl $ FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2821)     在   com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)     在   com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)     在   com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)     在   com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)     在   com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)     在   com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)     在   com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)     在javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)     在   swingJava.LanguageTranslator.languageParser(LanguageTranslator.java:33)     在swingJava.IHelp $ 1.actionPerformed(IHelp.java:76)at   javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)     在   javax.swing.AbstractButton中的$ Handler.actionPerformed(AbstractButton.java:2348)     在   javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)     在   javax.swing.JToggleButton $ ToggleButtonModel.setPressed(JToggleButton.java:308)     在   javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)     在java.awt.Component.processMouseEvent(Component.java:6533)at   javax.swing.JComponent.processMouseEvent(JComponent.java:3324)at   java.awt.Component.processEvent(Component.java:6298)at   java.awt.Container.processEvent(Container.java:2236)at   java.awt.Component.dispatchEventImpl(Component.java:4889)at   java.awt.Container.dispatchEventImpl(Container.java:2294)at   java.awt.Component.dispatchEvent(Component.java:4711)at   java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)     在   java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)     在java.awt.Container.dispatchEventImpl(Container.java:2280)at   java.awt.Window.dispatchEventImpl(Window.java:2746)at   java.awt.Component.dispatchEvent(Component.java:4711)at   java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)at at   java.awt.EventQueue.access $ 500(EventQueue.java:97)at   java.awt.EventQueue $ 3.run(EventQueue.java:709)at   java.awt.EventQueue $ 3.run(EventQueue.java:703)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)     在   java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)     在java.awt.EventQueue $ 4.run(EventQueue.java:731)at   java.awt.EventQueue $ 4.run(EventQueue.java:729)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)     在java.awt.EventQueue.dispatchEvent(EventQueue.java:728)at   java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)     在   java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)     在   java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)     在java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

0 个答案:

没有答案