64768

Parsing French text with simple-Framework not working

Question:

I'm using simpleFramework for parsing an xml file in my android app. My problem is in parsing french text like lets say this tag

<TagName>écrite</TagName>

The result I will receive when parsing is something like this "écrite" This is encoding (french) problem in the simpleFramework xml. How can avoid that and have my text "écrite"

the xml header has utf8 :

<?xml version="1.0" encoding="UTF-8"?>

Answer1:

I have hit this issue before whilst using a SAX parser. When reading the file with a Java InputStream you need to specify the encoding of the stream in code- perhaps by reading the first line of the file as you have shown. Here is the code for assigning the encoding;

SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); final SAXParser saxParser = saxParserFactory.newSAXParser(); // Note the encoding on the reader... final Reader reader = new InputStreamReader(<your file stream>, "UTF-8"); final InputSource inputSource = new InputSource(reader); inputSource.setEncoding("UTF-8"); saxParser.parse(inputSource, <some handler>);

Hope that helps. If not- post back with how you are reading the XML file.

Recommend

  • Why do I have to use LD_PRELOAD for libcl.2 to use XML::LibXML::Common on HP/UX?
  • getting bad request while using passport in login form
  • java - memory usage
  • Class works not correct. How to make it better?
  • CodeIgniter - Autoload
  • How can we extract the main verb from a sentence?
  • ANTLR4: Unrecognized constant value in a lexer command
  • Python: how to split and return a list from a function to avoid memory error
  • How to parse Java properties which contains variables?
  • Treetop basic parsing and regular expression usage
  • Xamarin PCLCrypto SHA256 give different hash
  • How to extract text from a PDF and decode characters?
  • Regex for Specific Tag
  • apply a javascript function to draggable copy
  • Is it possible to run clang with llc flags
  • Consuming a WCF service in a Java Client using wsHttpBinding
  • Exception gevent.hub.LoopExit: LoopExit('This operation would block forever',)
  • How can I include If-None-Match header in HttpRequestMessage
  • Adding elements to a huge XML file
  • saving file generated by TCPDF
  • How to view images from protected folder with php?
  • how to avoid repetitive constructor in children
  • How integrated is Collada to OpenGL ES
  • How to get Eclipse Oxygen to run on Java 9
  • Textfile Structure (tables)
  • Why Encoding.ASCII != ASCIIEncoding.Default in C#?
  • Jackson Parser: ignore deserializing for type mismatch
  • Control modification in presentation layer
  • Encrypt data by using a public key in c# and decrypt data by using a private key in php
  • Different response to non-authenticated users and AJAX calls
  • SSO with signing and signature validation doesn't work
  • Deserializing XML into class C#
  • vba code to select only visible cells in specific column except heading
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Data Validation Drop Down Box Arrow Disappearing
  • AngularJs get employee from factory
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Authorize attributes not working in MVC 4
  • costura.fody for a dll that references another dll
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize