Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 438427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:40:38+00:00 2026-05-12T20:40:38+00:00

SAX keeps on dying on the following exception: Invalid byte 2 of 3-byte UTF-8

  • 0

SAX keeps on dying on the following exception:

Invalid byte 2 of 3-byte UTF-8 sequence

The problem is its mostly correctly UTF-8 encoded but there are a few errors in it. We cannot get a new version of the file, we have to use this file.

So how do we tell SAX to ignore invalid character sequences, or clean up the UTF-8 file so that it doesn’t have invalid UTF-8 sequences?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:40:38+00:00Added an answer on May 12, 2026 at 8:40 pm

    I would suggest that you clean up the file as a completely separate step from parsing it as XML.

    UTF-8 is a fairly easy encoding to understand; this web page shows how UTF-8 is meant to be formed. I suggest you write a program which reads in your input file and writes out a new file. It will read byte by byte, only writing out a character when it sees that it has been validly formed. When it sees an invalid byte, it would write out the string “UTF8ERROR” or some other easily-findable token which wouldn’t occur naturally in the input data. It would then skip the rest of the character.

    Afterwards, you can check where the errors have occurred and fix up the data… then parse it as normal.

    This way you’ll see how widespread the errors are, see if there’s any pattern to them, and potentially be able to correct them. If you’re going to receive more data from the same source, I’d strongly encourage you to tell them about the issue… it may indicate a more serious problem on their side.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sax parser throws exception when I parse following file <?xml version='1.0' encoding='EUC-JP'?> <note> <to>George</to>
I am using SAX to parse some XML. Let's say I have the following
org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for
I want to sax-parse in nokogiri, but when it comes to parse xml element
I have a problem with using the SAX parser to parse a XML file.
I just pass to Sax parser but now i cant able to do that.
I've been going over the Poco SAX parser header files a few times but
I am using the SAX Parser for XML Parsing. The problem is for the
I am using the SAX Parser for XML Parsing. The problem is if I
I have a sax parser with an xml tag that contains the following text:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.