Comments (12)
@sharukhshaik126 you'll need to provide the name of the character encoding when you create the EDIStreamReader
.
Something like this (I am only guessing on the encoding in this example):
EDIStreamReader ediReader = inputFactory.createEDIStreamReader(inputStream, "ISO-8859-1");
from staedi.
Let me try with different encoding "UTF-8" and ISO-8859-1 , Thanks @MikeEdgar
from staedi.
Great news! Thanks for the update @sharukhshaik126 . I'll go ahead and close the issue, but please re-open if this still isn't resolved in your opinion and we'll discuss further.
from staedi.
Hi @sharukhshaik126 , what is the character encoding of the data you are reading? You can use one of the overloads of EDIInputFactory#createEDIStreamReader
to provide the correct encoding for your input.
from staedi.
@MikeEdgar actually when i tried to parse edi file with accent marks it throw below exception :
Unable to Stream EDI File : Error parsing input in segment NM1 at position 767, element 2
the same segment with accent marks working fine in windows env and it throws above exception in linux env, even if not specify char set encoding to edistreamreader class.
my code block :
EDIInputFactory inputFactory = EDIInputFactory.newFactory();
inputFactory.setProperty(EDIInputFactory.EDI_IGNORE_EXTRANEOUS_CHARACTERS, true);
InputStream inputStream = new FileInputStream(sourceFile);
EDIStreamReader ediReader = inputFactory.createEDIStreamReader(inputStream);
from staedi.
FYI that the default is UTF-8
if nothing is given.
from staedi.
Thanks , will try to define exact charset encoding to parse it. will update you here.
from staedi.
@sharukhshaik126 any luck?
from staedi.
@MikeEdgar No in linux still it throws exception after setting encoding to UTF-8
fail to parse edi file : /tmp/test/Halin_C_frdsw.txt | UTF-8
io.xlate.edi.stream.EDIStreamException: Error parsing input in segment NM1 at position 767, element 2
at io.xlate.edi.internal.stream.StaEDIStreamReader.lambda$executeTask$1(StaEDIStreamReader.java:186)
at io.xlate.edi.internal.ThrowingRunnable.run(ThrowingRunnable.java:19)
at io.xlate.edi.internal.stream.StaEDIStreamReader.executeTask(StaEDIStreamReader.java:181)
at io.xlate.edi.internal.stream.StaEDIStreamReader.nextEvent(StaEDIStreamReader.java:212)
at io.xlate.edi.internal.stream.StaEDIStreamReader.next(StaEDIStreamReader.java:241)
at com.mage.edireader.EDIFileParser.main(EDIFileParser.java:79)
Caused by: java.nio.charset.MalformedInputException: Input length = 1
at java.base/java.nio.charset.CoderResult.throwException(CoderResult.java:274)
at io.xlate.edi.internal.stream.tokenization.Lexer.readCharacter(Lexer.java:339)
at io.xlate.edi.internal.stream.tokenization.Lexer.readCharacterUnchecked(Lexer.java:313)
at io.xlate.edi.internal.stream.tokenization.Lexer.parse(Lexer.java:192)
at io.xlate.edi.internal.stream.tokenization.Lexer.parse(Lexer.java:174)
at io.xlate.edi.internal.ThrowingRunnable.run(ThrowingRunnable.java:17)
... 4 more
Exception in thread "main" io.xlate.edi.stream.EDIStreamException: Exception flushing output stream in segment NM1 at position 767, element 2
at io.xlate.edi.internal.stream.StaEDIStreamWriter.flush(StaEDIStreamWriter.java:240)
at io.xlate.edi.internal.stream.StaEDIStreamWriter.close(StaEDIStreamWriter.java:230)
at com.mage.edireader.EDIFileParser.main(EDIFileParser.java:187)
Caused by: java.io.IOException: Stream Closed
at java.base/java.io.FileOutputStream.writeBytes(Native Method)
at java.base/java.io.FileOutputStream.write(FileOutputStream.java:354)
at java.base/sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:233)
at java.base/sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:312)
at java.base/sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:316)
at java.base/sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:153)
at java.base/java.io.OutputStreamWriter.flush(OutputStreamWriter.java:251)
at io.xlate.edi.internal.stream.StaEDIStreamWriter.flush(StaEDIStreamWriter.java:237)
... 2 more
from staedi.
Did you also try with ISO-8859-1
? As far as I can tell it does include í
and é
characters.
from staedi.
@sharukhshaik126 can you possibly provide a test file without sensitive data that I can use to reproduce the issue? Using the sample text you gave originally I haven't been able to trigger any errors.
from staedi.
@MikeEdgar after using charger encode ad ISO-8859-1
The EDI file parsed successfully
from staedi.
Related Issues (20)
- Repetition Elements are not being correctly identified HOT 3
- Error reported when reading ANSI encoded txt file HOT 27
- Missing Mandatory Segments HOT 8
- Does enumerated elements really requires minLength and maxLength? HOT 12
- Reporting a vulnerability HOT 2
- How to apply relational condition in schema HOT 11
- X12 unexpected segment error occurred when first segment of loop is missing HOT 5
- Support multiple ISA segments in an X12 EDI file
- Validator should be reset at end of interchange
- titles for segments like BGN, ST, INS are not accessible in 834 EDI HOT 1
- Adding condition to writeSegment HOT 4
- Option to ignore repetition separator in the ST/SE segments HOT 8
- default decimal mark is point (.) when UNA segment is not present HOT 2
- HL Segment is not interpreted correctly by ReaderService HOT 17
- How to define element inside element in schema? HOT 7
- How to process large EDI files in reader service HOT 5
- Edi 835 Never Emitting a START_TRANSACTION HOT 3
- dots in an element in the ISA results in ELEMENT_OCCURRENCE_ERROR HOT 2
- Improper parse of simple 837 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from staedi.